-
March 12th, 2013, 01:04 PM
#1
Using a C++ DLL with C#
I have a 3rd party dll written in VC6.0 that I want to use within a C# application. When I call one of the exported functions I get a can't find entry point exception.
The dll is called diodrv.dll and there are 4 exported functions. Dumpbin and Depends both report this:
File Type: DLL
Section contains the following exports for diodrv.dll
ordinal hint RVA name
1 0 00001110 ?CloseDio@@YGXXZ
2 1 00001040 ?CreateDio@@YGKXZ
3 2 00001080 ?ReadDioReg@@YGKK@Z
4 3 000010D0 ?WriteDioReg@@YGXKK@Z
I have the source code and VC6 project for the dll. The function definitions are like this:
Code:
#define DIODRV_API __declspec(dllexport)
DIODRV_API DWORD __stdcall CreateDio(void);
My C# for importing the functions is this:
Code:
[DllImport("diodrv.dll")]
static extern Int32 CreateDio();
What's the best way to get access to these functions?
Thanks
-
March 12th, 2013, 02:02 PM
#2
Re: Using a C++ DLL with C#
This isn't really my area but you might try setting ExactSpelling to false. See http://msdn.microsoft.com/en-us/library/7b93s42f.aspx
-
March 12th, 2013, 02:24 PM
#3
Re: Using a C++ DLL with C#
The name mangling is messing you up.
-
March 12th, 2013, 02:48 PM
#4
Re: Using a C++ DLL with C#
Originally Posted by Arjay
The name mangling is messing you up.
OK.. Is there some way to rebuild the dll such that the names aren't mangled?
-
March 12th, 2013, 03:21 PM
#5
Re: Using a C++ DLL with C#
Originally Posted by Dave C
OK.. Is there some way to rebuild the dll such that the names aren't mangled?
I would use a .def file.
http://msdn.microsoft.com/en-US/libr...(v=vs.80).aspx
-
March 14th, 2013, 11:46 AM
#6
Re: Using a C++ DLL with C#
Thank you Arjay - the DEF file worked.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|