我很抱歉这是加载 dll 的经典问题。但我无法解决这个基本问题:我有一个插件文件路径,我想将这些程序集加载到新域中,但我不能这样做。首先; 这是一个网络应用程序,我的代码如下:感谢您的帮助:
foreach (var filePath in arryFiles)
{
Assembly asm = Assembly.LoadFile(filePath.ToString());
AppDomainSetup domainSetup = new AppDomainSetup();
domainSetup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
domainSetup.DisallowBindingRedirects = false;
domainSetup.DisallowCodeDownload = true;
domainSetup.LoaderOptimization = LoaderOptimization.SingleDomain;
domainSetup.ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
ApplicationHost = AppDomain.CreateDomain("Ops.Mgr.Service", null, domainSetup);
// how to load into domain my assembly...
}
谢谢你的帮助...