C # assembly.load from byte []

I have an EXE loaded into a byte array and I am trying to load it into an assembly object using Assembly.Load. I am trying to download errors.

Here is the code that throws the exception:

Assembly a = Assembly.Load(bin);

      

bin is my byte array loaded from EXE.

Here is the exception I'm getting:

Could not load file or assembly "109,590 bytes loaded from calc_tester, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null" or one of its dependencies. An attempt was made to load a program with an incorrect format.

Any help is appreciated.

0


source to share


2 answers


Make sure the file you are trying to download is a managed .NET exe / dll.



+4


source


I'm not sure, but since this is an EXE, could it fail due to unmanaged headers in the EXE?



Why not just load LoadFrom (filename)?

0


source







All Articles