Autofac Losing Registrations on Web.Config Edit

会有一股神秘感。 提交于 2019-12-05 16:56:54

I think the problem is that 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.

Try using the GetReferencedAssemblies method on System.Web.Compilation.BuildManager to get a list of the referenced assemblies instead.

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!