Skip to content

Latest commit

 

History

History
17 lines (10 loc) · 1.31 KB

iis-restart.rst

File metadata and controls

17 lines (10 loc) · 1.31 KB

Why aren't my assemblies getting scanned after IIS restart?

Sometimes you want to use the assembly scanning <../register/scanning> mechanism to load up plugins in IIS hosted applications.

When hosting applications in IIS all assemblies are loaded into the AppDomain when the application first starts, but when the AppDomain is recycled by IIS the assemblies are then only loaded on demand.

To avoid this issue use the GetReferencedAssemblies() method on System.Web.Compilation.BuildManager to get a list of the referenced assemblies instead:

csharp

var assemblies = BuildManager.GetReferencedAssemblies().Cast<Assembly>();

That will force the referenced assemblies to be loaded into the AppDomain immediately making them available for module scanning.

Alternatively, rather than using AppDomain.CurrentDomain.GetAssemblies() for scanning, manually load the assemblies from the filesystem. Doing a manual load forces them into the AppDomain so you can start scanning.