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

↘锁芯ラ 提交于 2019-12-23 07:36:12

问题


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?


回答1:


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




回答2:


You can avoid this by checking in VS :

Tools -> Options -> Nuget Package Manager -> Skip applying binding redirects



来源:https://stackoverflow.com/questions/17164516/why-are-all-my-web-configs-updated-with-an-assembly-redirect-when-installing-aut

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