Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / March 2007

Tip: Looking for answers? Try searching our database.

how to use VC++ dll in .net

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nicol - 02 Mar 2007 04:44 GMT
Hi,

I am having one VC++ dll. I need to refer this dll form C# web site. When I
try to add the dll as reference it says the "dll should be com dll or
assembly". So I understood I shouldnt use the VC++ dll as it is. I created a
serviced component so called wrapper class. Then I tried to add this wrapper
dll to my .net web site.
My wrapper looks like The project is built. when i run the application at
the line of calling VC++ function thro' wrapper class it throws an exception
as

[DllImport("a.dll", EntryPoint = "fun1")]
       public static extern int fun1(int p1, int p2, int p3, int p4, ref
string p5);

a.dll->VC++ dll
fun1-> function name

The matching function in VC++ looks like
short CNK::fun1(ULONG p1,ULONG p2,ULONG p3,ULONG p4,WCHAR* p5)

Is the parameter data type matching with vc++ and .net is correct?

"Attempted to read or write protected memory. This is often an indication
that other memory is corrupt".

Am I anyway wrong here.
Kindly help me.
Tx in advance
Mattias Sjögren - 02 Mar 2007 05:46 GMT
>[DllImport("a.dll", EntryPoint = "fun1")]
>        public static extern int fun1(int p1, int p2, int p3, int p4, ref
>string p5);

Try it with

[DllImport("a.dll", EntryPoint = "fun1", CharSet=CharSet.Unicode)]
public static extern short fun1(..., string p5);

Mattias

Signature

Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.