tags:

views:

66

answers:

2

Received an unmanaged C++ dll with instance functions which need to be called from my C#. need to write a wrapper C++ dll to bridge the C# and original C++ dll as suggested by experts here. it is new to me and want to learn from you.

Header file of the original C++ dll likes this:

class EXPORT_MACRO NB_DPSM 
{ 
private: 
    string sFileNameToAnalyze ; 

public: 
    NB_DPSM(void); 
    ~NB_DPSM(void); 

    void setFileNameToAnalyze(string FileNameToAnalyze) ;     
    int WriteGenbenchData(string& message) ; 
}; 

Start from a Class Library project template or CLR Empty Project template?

What's the wrapper code should look like?

Anywhere has step by step example for this?

thanks,

A: 

Hi,

1) Need list of functions exported by the dll, which should be available in the header file. 2) Do DllImports for the functions you want to use 3) Marshal in/out parameters appropriately

This link should explain in more detail, http://msdn.microsoft.com/en-us/library/aa288468(VS.71).aspx

Nemo
A: 

Oops, didn't read the question quite correctly. Check out this article, http://www.codeguru.com/Cpp/Cpp/cpp_managed/interop/article.php/c6867/

Nemo