I have a c++ dll, which at a certain point, needs to delegate a task to a dll written in .Net. For this i Created a c++/cli static library which consumes/uses the .net dll to achive some TASK. Then i statically link the c++/cli static lib with c++ dll. It looks something like this.
cli.aTask() netdll.aTask()
c++ dll ----------> c++/cli ----------------> .net dll
< static link > <normal assembly inclusion>
Now, the connection b/w c++dll and c++/cli is fine. i can do anything using .net library in c++/cli layer and then call this from c++dll. but when i create an object of a class from .net dll, or access a static method of .net dll class, i get exception in c++dll (actually c++dll crashes, no exceptions). below is the msg i got.
foo.exe is using c++dll
Unhandled exception at 0x7c812aeb in "foo.exe": OxE0434f4d: 0xe0434f4d.
c++dll code calling cli method:
CLILibrary::CCLILib lib;
lib.GetUsersInput();
cli code calling .net dll:
DotNetLibrary::DotNetClass::aMethod(); // static method`
.net dll class code:
namespace DotNetLibrary
{
public class DotNetClass
{
public DotNetClass(){}
public static void aMethod(){}
}
}
Now, if i dont use DotNetLibrary::DotNetClass
in any way in c++/cli lib, then exception stops coming.
Please help. my aim is to call .net lib from c++ dll, if there is a better way, then it will be nice too. thanks in advance.