Is there a way to configure the initial AppDomain?

I want to make my main AppDomain ShadowCopyAssembliesset to true.

Is there something I can do (for example, maybe a manifest parameter that I don’t have) that will allow the first AppDomain loaded into my executable to have this property equal to true, or is this my only option for creating a second AppDomain and my program does the bulk of the work in this 2nd domain?

The target environment is a self-service service, but knowing how to do this for console or Windows applications would be nice to know.

+4
source share
1 answer

, , , App.config. <appDomainManagerType> <appDomainManagerAssembly> , AppDomainManager.

Config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
    <runtime>
      <appDomainManagerType value="DomainManager.ShadowDomainManager" />
      <appDomainManagerAssembly
         value="DomainManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
    </runtime>
</configuration>

:

using System;

namespace DomainManager
{
    public class ShadowDomainManager : AppDomainManager
    {
        public override void InitializeNewDomain(AppDomainSetup appDomainInfo)
        {
            base.InitializeNewDomain(appDomainInfo); //Currently does not do anything.
            appDomainInfo.ShadowCopyFiles = "true";
        }
    }
}

ShadowCopyFiles, true.

+4

Source: https://habr.com/ru/post/1537909/


All Articles