我是 appdomain 概念的新手。它在这里指出,卷影副本会创建您正在引用的程序集的副本,但是当我检查我的 ShadowCopyDirectories 时,它是空的。
这是我的代码:
AppDomainSetup sandboxDomainSetup = new AppDomainSetup();
sandboxDomainSetup.ApplicationBase = @"D:\Testing\AppDomainTestProject\MainUI\bin\Debug";
sandboxDomainSetup.ShadowCopyFiles = "true";
string appData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
string tempfolder = Path.Combine(appData, "TestAppDomain"); //C:\ProgramData\TestAppDomain
if (!Directory.Exists(tempfolder))
{
Directory.CreateDirectory(tempfolder);
}
sandboxDomainSetup.ShadowCopyDirectories = tempfolder;
sandbox = AppDomain.CreateDomain("MyAppDomain", null, sandboxDomainSetup);
Assembly sandboxAssembly = Assembly.LoadFrom(assemblyPath.ToString());
var instance = sandbox.CreateInstance(sandboxAssembly.GetName().Name, sandboxAssembly.GetTypes().FirstOrDefault().FullName);
if (instance != null)
{
object obj = instance.Unwrap();}
我错过了什么吗?谢谢