Click to See Complete Forum and Search --> : How do I call C# dlls ala C++


gmanion
November 23rd, 2006, 11:48 PM
Hi, I can call C++ dlls written in VC5 and .NETwith the following declarations...
extern "C" {

__declspec(dllexport) int CallFromAV1( char *lpParam );

__declspec(dllexport) int TestCallBackFromAV1( char *lpParam );

}

How do I do the same from within a C# .NET dll?

Many thanks in advance....

Glenn Manion
GIS R&D Unit.
NPWS, NSW.
Australia

naveenl
November 24th, 2006, 01:00 AM
[DllImport("dll_name.dll")]
int CallFromAV1( char *lpParam );

[DllImport("dll_name.dll")]
int TestCallBackFromAV1( char *lpParam);

I gues this should be fine.......

Zaccheus
November 24th, 2006, 03:23 PM
I think that needs to be:

[DllImport("dll_name.dll")]
int CallFromAV1( StringBuilder lpParam );

[DllImport("dll_name.dll")]
int TestCallBackFromAV1( StringBuilder lpParam);

and you also need to specify that the calling convention is cdecl (which I'm not sure how to do).

creatorul
November 24th, 2006, 06:44 PM
[DllImport("dll_name.dll",CallingConvention=CallingConvention.Cdecl)]