Run exe file added as resource in visual studio

2020-03-04 09:11发布

Plainly put, I have added as a resource to a visual studio project an exe file. How do I run this file? I'm coding in c#.

2条回答
别忘想泡老子
2楼-- · 2020-03-04 09:33

You must use Process.Start method. See it in msdn

查看更多
姐就是有狂的资本
3楼-- · 2020-03-04 09:42

You can take Resource as byte[]

byte[] myResBytes = ...;
Assembly asm = Assembly.Load(myResBytes);
// search for the Entry Point
MethodInfo method = asm.EntryPoint;
if(method == null) throw new NotSupportedException();
// create an instance of the Startup form Main method
object o = asm.CreateInstance(method.Name);
// invoke the application starting point
method.Invoke(o, null);

Also see here for more details

Hope this helps

查看更多
登录 后发表回答