Geeks With Blogs
Rohit Gupta Engaging talk on Microsoft Technologies ....My Resume

If you see Nuget adding bindingRedirect to your app.config , when doing updates to existing assemblies, and if you feel this was not what you expected then read on.

Here is an example of a bindingRedirect added to the web.config file:

   1: <runtime>
   2:   <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
   3:     <dependentAssembly>
   4:       <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
   5:       <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
   6:     </dependentAssembly>
   7:   </assemblyBinding>
   8: </runtime>

An example of a bindingRedirect being added is when you first add FluentNHibernate package and then add the NHibernate package explicitly.
When FluentNHibernate is added to your project, it also adds a reference to NHibernate 3.1.4.0 as well, thus now when we add a reference to NHibernate explicitly it will update the NHibernate dll to 3.2.0.0 and since the NHibernate DLL versions are different, nuget also adds a bindingRedirect element to your projects app.config/web.config file as well.

Hence the workaround to this solution is not to add the NHibernate dll explicitly since FluentNHibernate depends on NHibernate and expects NHibernate 3.1.4.0 DLL to be present, if it does not find a bindingRedirect in the app.config file, it will not be able to load the NHibernate 3.2.0.0 dll.

Figured this out the hard way so hope this will help someone Smile

Posted on Wednesday, April 25, 2012 1:23 AM | Back to top


Comments on this post: When Nuget adds bindingRedirect elements to the app.config for assemblies

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Rohit Gupta | Powered by: GeeksWithBlogs.net