我使用 c# 4.0 和一个控制台应用程序只是为了测试,下面的代码确实给出了一个异常。
AppDomainSetup appSetup = new AppDomainSetup()
{
ApplicationName = "PluginsDomain",
ApplicationBase = AppDomain.CurrentDomain.BaseDirectory,
PrivateBinPath = @"Plugins",
ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
};
AppDomain appDomain = AppDomain.CreateDomain("PluginsDomain", null, appSetup);
AssemblyName assemblyName = AssemblyName.GetAssemblyName(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins", "sample.dll"));
Assembly assembly = appDomain.Load(assemblyName); //This gives an exception of File not found
AppDomain.Unload(appDomain);
在我创建的 AppDomain 上使用Load时,我不断收到 File not found 异常。
谢谢。