<configuration>
<runtime>
<appDomainManagerType value="company.project.Data.Runtime.ApplocalAppDomainManager" />
<appDomainManagerAssembly value="company.project.ManagedData, Version=15.100.0.0, PublicKeyToken=89845dcd8080cc91, Culture=neutral" />
</runtime>
</configuration>
1.首先通过*.exe.config当中指定的appDomainManagerAssembly(对应的dll)当中的appDomainManagerType
2.ApplocalAppDomainManager 继承AppDomainManager, 重载InitializeNewDomain方法。
namespace Company.Project.Data.Runtime
{
internal class ApplocalAppDomainManager : AppDomainManager
{
public override void InitializeNewDomain(AppDomainSetup appDomainInfo)
{
string configFilePath = GetConfigurationFilePath();
string configTemplatePath = Path.Combine(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName), " "default.applocal.config");
GenerateConfigurationFile(configFilePath, configTemplatePath);
appDomainInfo.ConfigurationFile = configFilePath;
base.InitializeNewDomain(appDomainInfo);
}
}
}