Groups | Blog | Home
all groups > dotnet interop > august 2003 >

dotnet interop : Syntax of DllImport's EntryPoint field


Wu YiFei
8/28/2003 12:43:24 AM
Hi,

I try to call c function in C#,What is the syntax of
DllImport's EntryPoint field?
Why some of extern method need to point out this field
while some of them do not need?

In my project,
A C function defination is
//****************
__declspec(dllexport) SbVec2s
SoWinFullVwrGetViewportRegionSizePixels(SoWinFullViewer*
pViewer);
//****************

The corresponding C# wrapper is
//****************
[DllImport
("InventorCD.dll",CallingConvention=CallingConvention.Cdecl
,EntryPoint="?SoWinFullVwrGetViewportRegionSizePixels@@YA?
AVSbVec2s@@PAVSoWinFullViewer@@@Z")]
protected static extern SbVec2s
SoWinFullVwrGetViewportRegionSizePixels(System.IntPtr
pViewer);
//****************

The code is fine to run.

But when I try to change the C function defination to
//*****************
__declspec(dllexport) SbVec2s
SoWinFullVwrGetViewportRegionSizePixels(SoWinFullViewer*
pViewer, int iTest);
//*****************

Making no change to the C# wrapper, calling the C# wrapper
will throw exception as,
"
An unhandled exception of
type 'System.EntryPointNotFoundException' occurred in
openinventor.net.dll

Additional information: Unable to find an entry point
named ? in DLL InventorCD.dll.
"
I think I should modify the DllImport.EntryPoint value,
but how to do it? the working code is got from somewhere
else, not written by me.

Thanks,
Wu YiFei


Vadim Melnik
8/28/2003 11:14:53 AM
Hi,

[quoted text, click to view]


Seems like EntryPoint field should be updated, it's due to the fact C
decorated name used, and after function parameters changed, decorated name
changed as well. For example run the following command line:

undname
?SoWinFullVwrGetViewportRegionSizePixels@@YA?AVSbVec2s@@PAVSoWinFullViewer@@
@Z


it outputs:

Undecoration of :-
"?SoWinFullVwrGetViewportRegionSizePixels@@YA?AVSbVec2s@@PAVS
oWinFullViewer@@@Z"
is :- "class SbVec2s __cdecl SoWinFullVwrGetViewportRegionSizePixels(class
SoWin
FullViewer *)"


See "dumpbin /EXPORTS " or Dependens VS tool allow to find exported function
name.

...
Regards,
Vadim.








AddThis Social Bookmark Button