C# – appdomain c++ c#


when we write
Assembly asm = AppDomain.CurrentDomain.Load(SomeByteArray);

when SomeByteArray read from .net .exe all is ok, and when from c++, error.

for this function is important using .net exe ?

if yes please other way to do this.


Best Solution

Are the calling assembly and the one you're loading both the same kind of build (x86, x64 or AnyCpu)? You can check the build by looking at them in ILDASM (look at the manifest, scroll to bottom and look for corflags).

If you built both assemblies yourself, then just check the property pages of the project for how you built it.

You either have to make sure they are the same, or if the .exe is AnyCpu, then the assembly you are loading must match whatever the OS is. Meaning it must be x86 on a 32-bit OS or x64 on a 64-bit OS.

(this is all assuming that SomeByteArray was loaded from the file correctly)