Question

On a Windows XP system, I'm writing a Mangaged C++ library which calls code in a C# Assembly. Unfortunately, as soon as I start referencing a symbol in the C# Assembly, running the Managed C++ library fails with this error (I copied this from the XP crash dialog):

EventType : clr20r3
P1 : treeviewdemo.exe
P2 : 0.0.0.0
P3 : 4a5d6d62
P4 : system.windows.forms
P5 : 2.0.0.0
P6 : 4889dee7
P7 : 12fc     
P8 : ac
P9 : system.io.filenotfoundexception    

The Manged C++ library is basically just:

#using "C:\\MyCSharpAssembly.dll";

__declspec(dllexport) void callMangagedCode() {
  ManagedObject ^o = nullptr;
}

The '#using' itself doesn't seem to cause any problem, but as soon as I start using symbols form the C# DLL, I get problems. Does anybody know what's going on?

The system.io.filenotfoundexception part makes me think that some DLL is not being found, but I have no idea which or where it's looking.

Was it helpful?

Solution

Are all the dependencies of MyCSharpAssembly.dll available on the same path? If you are not sure, try loading the C-Sharp Assembly in ILDasm Tool to find out what are its dependencies.

As a sanity check, also check that whether this C-Sharp DLL can be loaded from another C-Sharp executable or not.

OTHER TIPS

file no found?

the C# Assembly no found?

copy it to windows or system32 and have a try

if failure,try to register

Do you have access to the C# assemblies source code? Can you run your managed C++ code in the debugger? It would be worthwhile to see a stack trace of the exception, this might give you more hints as to what is happening when the exception occurs.

I'd suspect that the crash may be related to the operation you're doing. As Aamir mention, the other possibility may be a dependency of the C# assembly...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top