static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
byte[] bs = global::MyTest.Properties.Resources.LoginForm;
Assembly asm = Assembly.Load(bs);
MethodInfo info = asm.EntryPoint;
ParameterInfo[] parameters = info.GetParameters();
string[] args = new string[] { "Name", "Pwd" };
if ((parameters != null) && (parameters.Length > 0))
{ info.Invoke(null, (object[])args);
}
else
{
info.Invoke(null, null);
}
}
}
// 嵌入的A.exe如下
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new LoginForm(args));
}现在的问题是,运行后程序不报错,但嵌入的A.exe不显示出来!请问是什么问题,首先A.exe程序是C#程序,独立运行它是没有任何问题的!
改成
info.Invoke(null, new object[]{args});
试试