AppDomainSetup explained

AppDomainSetup is a properties bag. It stores various properties that affects binding decision in an appdomain, as well as other decision as well. MSDN documents each properties in AppDomainSetup. But there are a few properties that are not well explained by MSDN. This post attempts to clear them up.

I only discuss properties affecting binding decision. For things I do not discuss please consult MSDN document.

1. DisallowPublisherPolicy
    This is not to disallow publisher policy in this appdomain. Quite contrary, this is to disallow bypassing publisher policy. In application config file there is a tag <publisherPolicy apply=”yes|no”/> . If this tag is in app config, and apply is no, publisher policy will not be applied for this application. And DisallowPublisherPolicy is to disable this tag.

2. PrivateBinPathProbe
    The MSDN document is confusing. But the remark section describes its behavior correctly. It is actually a boolean value. If this is set, we will ignore the application base, and only probe the private bin path.

3. DynamicBase
    I wonder how many people can figure out what DynamicBase is just from reading MSDN documentation. This is a feature we designed for ASP.NET scenario. In ASP.NET you can put the code in the .aspx file. At runtime ASP.NET runtime compiles the code once, and re-use the compiled bits in subsequent requests until the page changes. Now where do the compiled bits go? According to probing rule, they needs to be in ApplicationBase. Does it mean you will see random goo show up in your application directory if you embed code inside your .aspx pages? No. Because ASP.NET uses the DynamicBase properties. If both DynamicBase and ApplicationName are set, DynamicBase+ApplicationName constitutes a dynamic directory. Fusion will probe ApplicationBase, as well as the dynamic directory, even though the dynamic directory may not under ApplicationBase. ASP.NET sets the DynamicBase property, and put the compiled bits in the corresponding dynamic directory. Fusion picks up bits from there.
    I’ll leave it as an exercise for the readers to figure out what is the DynamicBase set by ASP.NET.

4. CachePath/ShadowCopyDirectories/ShadowCopyFiles
    Please see my previous post “AppDomain and Shadow Copy

Comments (2)

  1. The daily list of stuff I found interesting while blogreading.