Search code examples
c#byte.net-assemblyfilestream

Run exe file from FileStream


I'm trying to run an exe file through filestream , but nothing is happens when I call the command.

My code:

string filePath = AppDomain.CurrentDomain.BaseDirectory + "OUT\\WAMServer.exe";

// read the bytes from the application exe file
FileStream fs = new FileStream(filePath, FileMode.Open);
BinaryReader br = new BinaryReader(fs);
byte[] bin = br.ReadBytes(Convert.ToInt32(fs.Length));
fs.Close();
br.Close();

// load the bytes into Assembly
Assembly a = Assembly.Load(bin);

Anyone have tips or a solution?


Solution

  • If you really want to start unmanaged application from byte array try this link https://stackoverflow.com/a/305319/820502