我写了一个简单的创建单独的AppDomain的行,但是得到FileNotFound的奇怪异常:无法加载文件或程序集......考虑到必要的参数被填充,这个问题让我非常困惑:
AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationBase = Assembly.GetExecutingAssembly().CodeBase;
Evidence evidence = new Evidence(AppDomain.CurrentDomain.Evidence);
evidence.AddAssembly(Assembly.GetExecutingAssembly().FullName);
evidence.AddHost(new Zone(SecurityZone.MyComputer));
AppDomain hostedAppDomain = AppDomain.CreateDomain("Demo", evidence, setup);
hostedAppDomain.AssemblyResolve += new ResolveEventHandler(hostedAppDomain_AssemblyResolve); **// Exception in this line**
答案 0 :(得分:0)
想出来......需要改变
setup.ApplicationBase = Assembly.GetExecutingAssembly().CodeBase;
到
setup.ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);