Interop c# and cpp unmanaged [modified]
-
Dear gurus, finally I get totally crazy with interoperability of un/managed code. I have the unmanged Cpp-Class "MyCppClass" with one simple member-function "add()". This class is not shown here. Now I build a managed wrapper class "MyCppClassWrapper". I create an instance of this wrapper in a C#-Program and then I want to call the method "add()".
#include "MyCppClass.h" namespace Managed { public ref class MyCppClassWrapper { MyCppClass *pInst; public: int add(int a, int b); }; } // implementation int MyCppClassWrapper::add( int a, int b) { return pInst->add(a,b); }
If I the program starts, I get a FileNotFoundException: "The specified module could not be found. (Exception from HRESULT: 0x8007007E)" But if I comment out "return pInst->add(a,b);" then everything works fine. It seems that I cannot call the function add() of the pInst-Pointer. I'm totally lostmodified on Wednesday, April 9, 2008 10:05 AM
-
Dear gurus, finally I get totally crazy with interoperability of un/managed code. I have the unmanged Cpp-Class "MyCppClass" with one simple member-function "add()". This class is not shown here. Now I build a managed wrapper class "MyCppClassWrapper". I create an instance of this wrapper in a C#-Program and then I want to call the method "add()".
#include "MyCppClass.h" namespace Managed { public ref class MyCppClassWrapper { MyCppClass *pInst; public: int add(int a, int b); }; } // implementation int MyCppClassWrapper::add( int a, int b) { return pInst->add(a,b); }
If I the program starts, I get a FileNotFoundException: "The specified module could not be found. (Exception from HRESULT: 0x8007007E)" But if I comment out "return pInst->add(a,b);" then everything works fine. It seems that I cannot call the function add() of the pInst-Pointer. I'm totally lostmodified on Wednesday, April 9, 2008 10:05 AM
Tomerland wrote:
But if I comment out "return pInst->add(a,b);" then everything works fine.
The code you posted does not show the
pInst
member being initialized. You can't use it without initializing it to a valid value. Oh and this is the wrong forum for your question. This is a C++/CLI question so if you need more information you should ask in that forum.led mike