这种方法,如下所示,大多数应用都很好。
FileStream fs = new FileStream(filePath, FileMode.Open); // read the bytes from the application EXE file
BinaryReader br = new BinaryReader(fs);
byte[] bin = br.ReadBytes(Convert.ToInt32(fs.Length));
fs.Close();
br.Close();
Assembly a = Assembly.Load(bin); // load the bytes into Assembly
MethodInfo method = a.EntryPoint; // search for the Entry Point
if (method != null)
{
// create an instance of the Startup form Main method
object o = a.CreateInstance(method.Name);
// invoke the application starting point
method.Invoke(o, null); //EXCEPTION THROWN HERE
}
然而,当我试图利用这一工具开始使用妇女论坛时,出现了一个例外:
Exception has been thrown by the target of an invocation.
The inner exception was of type System.IO.IOException:
Cannot locate resource mainwindow.xaml .
注:申请通常按规定进行罚款。 为了测试的目的,汇编了一份空壳体申请。