Note that there are some explanatory texts on larger screens.

plurals
  1. POAutofac Losing Registrations on Web.Config Edit
    primarykey
    data
    text
    <p>I have a layered web application that I built with ASP.NET MVC 4, WebAPI and some other components. I'm using the latest release of Autofac 2.6.2.859 as my DI container along with the MVC and WebAPI integrations. I have autofac modules setup in my different layers and I'm using the new RegisterAssemblyModules to scan the AppDomain assemblies for the various modules.</p> <p>On startup every works great. When I edit the web.config file and the application warms up, my registrations are lost. I get a DependencyResolutionException - </p> <blockquote> <p>None of the constructors found with 'Public binding flags' on type 'My.Class.Name' can be invoked with the available services and parameters:</p> </blockquote> <p>So my registrations are not being reloaded. Does anyone know how to address this issue? Should I put my initialization code somewhere else other than Application_Start() ?</p> <p><strong>UPDATE</strong></p> <p>Here's what my code looks like</p> <pre><code> public static class IoC { public static void Configure() { var builder = new ContainerBuilder(); var assemblies = AppDomain.CurrentDomain.GetAssemblies(); //Assembly Modules builder.RegisterAssemblyModules&lt;NSUTriviaModuleBase&gt;(assemblies); // Register API controllers using assembly scanning. builder.RegisterControllers(assemblies); // Register API controllers using assembly scanning. builder.RegisterApiControllers(assemblies); var container = builder.Build(); // Set the dependency resolver implementation. var resolver = new AutofacWebApiDependencyResolver(container); GlobalConfiguration.Configuration.DependencyResolver = resolver; DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload