Could not load file or assembly Autofac, Version=3.3.0.0 Could not load file or assembly Autofac, Version=3.3.0.0 asp.net asp.net

Could not load file or assembly Autofac, Version=3.3.0.0


You probably need a binding redirect in your web.config. Mine, for version 3.5, looks like:

  <dependentAssembly>    <assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />    <bindingRedirect oldVersion="0.0.0.0-3.5.0.0" newVersion="3.5.0.0" />  </dependentAssembly>


It needs the <role name>.dll.config file added to your Solution (same level as the web.config or app.config) and be set the Copy to Output Directory property to “Copy Always”. This file should contain the bindingRedirect settings. I've had the same error: FileLoadException: Could not load file or assembly in WebRole (recycling instance)

More info at Cloud Services roles recycling with the error “System.IO.FileLoadException: Could not load file or assembly”


I had this problem with a unit test library that I migrated from the old XAML builds to the new vNext builds. I had configured assembly version binding redirection for all libraries that use AutoFac. I still ended up with the problem in the output.

I eventually discovered that the binding redirect information is only output (in the bin folder) for the DLL corresponding to the project, and not all other DLLs that are included. In my case, I had a reference to another (unit test) library that also needed AutoFac. This library had unit tests in it that were also detected by the build process, and failed when run. The problem was that the binding redirects defined in the referenced library were not being applied because the referenced library's .config file was not present in the bin folder.

So I solved this by not having unit test libraries reference other unit test libraries. As a work-around, use a common code project, or a common C# project library for common code.

There is additional info about why assembly binding is required for AutoFac here: Why don’t all Autofac packages target the latest Autofac core?