Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are all my web.configs updated with an assembly redirect when installing autofac?

Tags:

nuget

autofac

I just installed autofac into one of my projects, call it project A, in a solution I have using nuget. For some reason all my web.config files, I have multiple web applications and apis in the solution, got updated with an assembly redirect like this one:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>

What does this mean assembly redirect mean? And how does the solution know that all these web.config files needed to be updated? Is it because my web applications references project A?

like image 560
Tomas Jansson Avatar asked Jun 18 '13 08:06

Tomas Jansson


1 Answers

This has nothing to do with Autofac, because it is nuget feature:

From the nuget-1.2 release notes:

Automatically Add Binding Redirects

When installing a package with strong named assemblies, NuGet can now detect cases where the project requires binding redirects to be added to the configuration file in order for the project to compile and add them automatically.

You can read more about why the assembly redericts are needed in the article mentioned also in the release notes: NuGet versioning Part 3: unification via binding redirects

Learning about the assembly rederiction in general you can start on MSDN: Redirecting Assembly Versions

like image 194
nemesv Avatar answered Sep 29 '22 19:09

nemesv