See this

Sujit Patil replied to sambath kumar at 03-Jul-08 04:30

  

When using the .Net compiler (or the VC6 compiler as well) with a ‘C’ project where the source file extension is *.cpp – you must either turn name mangling off by enclosing your public (__declspec(dllexport) = public in ‘C’) methods in a block defined as ‘extern “C”’ or use a .DEF file. I chose to use ‘extern “C”’. Name mangling is how C++ compilers distinguish overloaded methods with the same name. Note that you cannot overload any methods enclosed in ‘extern “C”. I believe with VC6 you can turn off mangling by simply changing the source extension to *.c but I have not tried this with VS.Net.

-         You can import mangled or any other public method by using the EntryPoint parameter for DllImport which will take either an ordinal index or the method name. I use both method name and ordinal position in the sample code to illustrate this point.

-         Dumpbin.exe which comes with VS.Net is indispensable when troubleshooting Dlls written in ‘C’. An example of how to use this and sample output is in the comments of the source code.

-         If you do not include the modifier __declspec(dllexport) in your ‘C’ Dll function definition (prototype in header [.h] file) and declaration (function body in *.c or *.cpp file) the method will not be exported as ‘public’ and the entry point will not show up in the binary dump of the Dll.

 

Go thr this link for more details;

 

http://www.codeproject.com/KB/cs/C_DLL_with_Csharp.aspx

 

Best Luck!!!!!!!!!!!!!!

Sujit.

 

 

 


Click here to sign in and reply. You could earn money via our $500 contest just for being helpful.
  Using C DLL with C# - sambath kumar  03-Jul-08 03:14 3:14:29 AM
      Check with these links - This will fix your issue - santhosh kumar  03-Jul-08 03:39 3:39:42 AM
      refer this link : - Deepak Ghule  03-Jul-08 03:52 3:52:59 AM
      See this - Sujit Patil  03-Jul-08 04:30 4:30:45 AM
      Solution to c dll - Umapathy Kaliaperumal  03-Jul-08 04:32 4:32:05 AM
      Reply - alice johnson  03-Jul-08 01:32 1:32:51 PM
View Posts