brumScouse
brumScouse

Reputation: 3226

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. I dont understand why some 86 assemblies are loaded in the first instance, i.e. when I deploy the app and then only 28 are loaded after the recycle.

What could be happening?

Upvotes: 1

Views: 787

Answers (1)

Cyril Durand
Cyril Durand

Reputation: 16187

It is a known behavior of IIS. After IIS recycle, assemblies are loaded on demand.

If you want to get all available assemblies, you can use GetReferencedAssemblies method on the System.Web.Compilation.BuildManager type.

For example :

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

Upvotes: 1

Related Questions