T
T
Troodi Larson2017-08-23 21:28:26
WPF
Troodi Larson, 2017-08-23 21:28:26

Running a byte array doesn't work?

FileStream fs = new FileStream(@"C:\Users\Родион\Desktop\chk.exe", FileMode.Open);
            BinaryReader br = new BinaryReader(fs);
            byte[] bin = br.ReadBytes(Convert.ToInt32(fs.Length));
            fs.Close();
            br.Close();
            Assembly a = Assembly.Load(bin);
            MethodInfo method = a.EntryPoint;
            object o = a.CreateInstance(method.Name);
            // invoke the application starting point
            method.Invoke(o, null);

Throws an exception
System.BadImageFormatException: "Не удалось загрузить файл или сборку "594432 bytes loaded from WindowsFormsApp7, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" либо одну из их зависимостей. Была сделана попытка загрузить программу, имеющую неверный формат."

Changed x64, x32 to no avail.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Makarov, 2017-08-24
@DmitryITWorksMakarov

is "chk.exe" exactly a .NET assembly?
does the .NET Framework version match?
Well, the digits must match...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question