我试图通过文件流运行一个exe文件,但是当我调用该命令时没有任何事情发生。从FileStream运行exe文件
我的代码:
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);
任何人有提示或解决方案?
请再具体些,你的意思是“什么也没有发生。”程序是否停止运行? 'a'是否被设置为'null'?是否引发异常?程序是否在'Assembly.Load'之后继续执行,就好像'Load'从未发生过一样? – 2015-02-11 02:36:09
只需用此代码点击按钮,什么都不会发生 – user3571412 2015-02-11 02:37:24
您确认您的路径正确吗?加载前请尝试将其吐出到控制台。 – 2015-02-11 02:38:15