开发者

C++ & C#, how to create wrapper dll in C++ for C# to call instance function in C++ dll?

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 FileN开发者_StackOverflow中文版ameToAnalyze) ;     
    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,


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜