Question

In one of the projects I am working the code dynamically loads in a .net DLL into a fully trusted Assembly using the Assembly.LoadFrom function. Up to now this has been working 100% without issue.

I now have a Visual C++ DLL compiled with /clr:pure that needs to get loaded using the above Assembly.LoadFrom. I get BadImageFormatException when I do which is really weird.

In the Visual C++ Project there are 3 types of CLR compile options:

/clr

/clr:pure

/clr:safe

As per the instructions given to me it needs to be compiled under /clr:pure. My problem is using /clr:pure throws the exception. If I change it to /clr it also throws an exception. If I change it to /clr:safe it loads in without throwing an exception (thisis where my testing ended).

So I guess this is really a two part question:

1) Why would /clr:safe work but not the other two?

2) How do I get it to work with /clr?

Thanks in advance!

Was it helpful?

Solution

After research this method can not load mixed assemblys. They can only be pure MSIL.

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