简体   繁体   English

在应用程序池回收期间,程序集是否从应用程序域中卸载?

[英]During an Application Pool recycle are assemblies unloaded from an app domain?

Ive just checked AppDomain.CurrentDomain.GetAssemblies before and after an App Pool recycle and it appears that is the case. 我已经在应用程序池回收之前和之后检查过AppDomain.CurrentDomain.GetAssemblies,看来确实如此。 I dont understand why some 86 assemblies are loaded in the first instance, ie when I deploy the app and then only 28 are loaded after the recycle. 我不明白为什么要在第一个实例中加载大约86个程序集,即,当我部署应用程序时,在回收之后仅加载28个程序集。

What could be happening? 可能会发生什么?

It is a known behavior of IIS. 这是IIS的已知行为 After IIS recycle, assemblies are loaded on demand. IIS回收后,程序集将按需加载。

If you want to get all available assemblies, you can use GetReferencedAssemblies method on the System.Web.Compilation.BuildManager type. 如果要获取所有可用的程序集,则可以对System.Web.Compilation.BuildManager类型使用GetReferencedAssemblies方法。

For example : 例如 :

IEnumerable<Assembly> assemblies = AppDomain.CurrentDomain.GetAssemblies();
if (HostingEnvironment.InClientBuildManager)
{
    assemblies = assemblies.Union(BuildManager.GetReferencedAssemblies().Cast<Assembly>());
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM