AppDomain.CurrentDomain.AssemblyResolve 只有在调试时在特定位置设置断点,程序才能正常运行?
wpf程序app1 和dll1在同一目录下,启动app1,可以正常运行。
现在将dll1进行了加密并命名为Min_dll1.dll,并且没有放在app1的exe的同一目录下
app2.exe
dll2.dll
app1.exe
dll/ Min_dll1.dll (当前目录的dll文件夹下)
用另一个wpf程序app2开辟一个新的Appdomin运行app1,并且添加了AppDomain.CurrentDomain.AssemblyResolve处理
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(wuutpoinhstujhnnxasjhgs_maigc);
Assembly wuutpoinhstujhnnxasjhgs_maigc(object sender, ResolveEventArgs args)
{
string module = wuutpoinhsajdkkqs_maigc(args.Name);
if (module.Substring(0, 4) == "Min_")
{
return hopdhhncndfgenga_maigc(module);
}
else
{
return tiijjjjqndfgenga_maigc(module);
}
}
Assembly hopdhhncndfgenga_maigc(string module)
{
string dll = Path.Combine(App.sAppStartPath + App.configer.GetNodeProperty("configuration//App//ref", "mine"), string.Format("{0}.dll", module));
***byte[] otherAssemblyBytes = Detools.DesDecryptBYTE(module, dll);
***return Assembly.Load(otherAssemblyBytes);
***}
调试提示FileNotFoundException,无法加载dll1.dll,只有在上面代码***处设置断点,再调试运行则可以正确运行