-1

我写了一个简单的行来创建单独的 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**
4

1 回答 1

0

想通了..需要改变

setup.ApplicationBase = Assembly.GetExecutingAssembly().CodeBase;

setup.ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
于 2013-05-24T10:37:42.490 回答