Keeping the versions of packages in sync was difficult today.
My MVC website must load and display a controller / view from another project. The assembly is in the bin folder and the objects are loaded using Structuremap. When running the website the debugger stopped with this error:
Could not load file or assembly ‘WebGrease, Version=188.8.131.52624,
Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its
dependencies. The located assembly’s manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
Seems to be a version difference between my MVC website and the loaded project. Visual Studio did supply me with a warning and a solution:
Found conflicts between different versions of the same dependent
assembly. In Visual Studio, double-click this warning (or select
it and press Enter) to fix the conflicts; otherwise, add the
following binding redirects to the “runtime” node in the
application configuration file:<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="0.0.0.0-184.108.40.20634" newVersion="220.127.116.1134" /> </dependentAssembly> </assemblyBinding>
But I don’t want to specify what version to use in my configuration.
The solution was to uninstall and (re)install a package
uninstall-package Microsoft.AspNet.Web.Optimization install-package Microsoft.AspNet.Web.Optimization
Now both projects use the 1.5.2 version of the WebGrease package. Only needed to figure out what package to re-install.