System.Web.Compilation.BuildManager equivalent for non-web applications

  • Thread starter Thread starter MJ
  • Start date Start date

MJ

New Member
Compared to \[code\]AppDomain.CurrentDomain.GetAssemblies()\[/code\], \[code\]BuildManager.GetReferencedAssemblies()\[/code\] (System.Web.Compilation.BuildManager) seems a more reliable way to get the assemblies that are referenced by an ASP.NET application, since AppDomain.GetAssemblies() only gets "the assemblies that have [already] been loaded into the execution context of this application domain". Iterating through all assemblies is an important tool for dynamically registering types at application start-up in your DI container and especially during application start-up chances are high that other assemblies are not loaded (where not needed) yet, and the composition root is the first one that needs them. It is therefore very important to have a reliable method to get the application's referenced assemblies.Although \[code\]BuildManager.GetReferencedAssemblies()\[/code\] is a reliable method for ASP.NET applications, I'm wondering what alternatives are available for other types of applications, such as desktop applications, windows services, and self-hosted WCF services.
 
Back
Top