Assembly.Load()関数でのメモリからのEXEファイルが重複していますが、この関数にバイト配列を渡すと、BadImageFomatException
アセンブリ名の重複型が発生します。Assembly.Load()名前が '
私のコードは次のとおりです。
try{
// prepare the Form to show balloontip
frmDefault frm = new frmDefault();
// prepare to load the application into memory (using Assembly.Load)
// 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);
// search for the Entry Point
MethodInfo method = a.EntryPoint;
if (method != null)
{
// create an istance of the Startup form Main method
object o = a.CreateInstance(method.Name);
Console.Write("Application started!");
method.Invoke(o, null);
}
else
{
// impossible to launch the application
Console.Write("Application error!");
}
}
catch
{
}
おそらく、コードの後にコードの代わりにコードをポストすることは、もっと役に立つでしょう。また、このコードはどこにありますか?それは複数回呼び出すことができますか?すでに参照されている、またはロードされているアセンブリと同じですか? – Kateract
あなたはそのアセンブリをどこから手に入れましたか?問題のタイプの名前で判断すると、それは難読化されていますか? –
それは複数回呼び出すことはできません。 – user3001228