我有以下代码将 DLL 加载到新的AppDomain
,我面临错误:
无法加载文件或程序集
请,任何线索我错过了什么?
const string pluginFolder = "Plugins";
var _domainSetup = new AppDomainSetup
{
ShadowCopyFiles = "true",
ShadowCopyDirectories = null,
CachePath = Path.Combine(Environment.CurrentDirectory, pluginFolder),
ApplicationBase = Environment.CurrentDirectory,
PrivateBinPath = Path.Combine(Environment.CurrentDirectory, pluginFolder)
};
var adi = new AppDomainInitializer(AppDomainInit);
_domainSetup.AppDomainInitializer = adi;
var PersonalDomain =
AppDomain.CreateDomain("SomeAppDomainName", null, _domainSetup);
var assemblyName = AssemblyName.GetAssemblyName(@"C:\myFile.dll");
var LoadedAssembly = PersonalDomain.Load(assemblyName);