日期:2014-05-18  浏览次数:20931 次

如何将exe文件放在资源文件中,并在程序中使用
将exe文件放在资源文件中,在按下Button后运行此文件

求具体代码

------解决方案--------------------
探讨
试了下,我没搞定,不过看看你的代码觉得快接近了...

------解决方案--------------------
[STAThread]
static void Main(string[] args)
{
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("NameSpace.Resources.Your.exe");
byte[] bs = new byte[stream.Length];
stream.Read(bs, 0, (int)stream.Length);
Assembly asm = Assembly.Load(bs);

MethodInfo info = asm.EntryPoint;
ParameterInfo[] parameters = info.GetParameters();
if ((parameters != null) && (parameters.Length > 0))
info.Invoke(null, (object[])args);
else
info.Invoke(null, null);
}
如果用到了Your.exe.config文件,注意要改成外部的out.exe.config,才不会出错