Autofac icon indicating copy to clipboard operation
Autofac copied to clipboard

System.IO.FileLoadException on builder.Build()

Open damooooooooooh opened this issue 12 years ago • 2 comments

After upgrading to Web Api 2.2 I get the following issue on calling IContainer container = builder.Build();

An exception of type 'System.IO.FileLoadException' occurred in Autofac.dll but was not handled in user code

Additional information: Could not load file or assembly 'Autofac.Integration.WebApi, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I am using Autofac.WebApi2 3.4.0 System.Web.Http 5.2.2.0

damooooooooooh avatar Oct 17 '14 21:10 damooooooooooh

Add a binding redirect to your web.config to redirect requests for version 3.0.0.0 to 3.4.0.0. Sometimes NuGet forgets to add it for you.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="Autofac.Integration.WebApi"
                                  publicKeyToken="17863af14b0044da"
                                  culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-3.4.0.0"
                                 newVersion="3.4.0.0" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

tillig avatar Oct 17 '14 22:10 tillig

Just the ticket. Thanks!

Sent from my iPhone

On 17 Oct 2014, at 23:07, Travis Illig [email protected] wrote:

Add a binding redirect to your web.config to redirect requests for version 3.0.0.0 to 3.4.0.0. Sometimes NuGet forgets to add it for you.

— Reply to this email directly or view it on GitHub.

damooooooooooh avatar Oct 17 '14 22:10 damooooooooooh