Introduction
today I updated my ASP.NET MVC application and I run into the following error (in german - sorry):
Die Datei oder Assembly "WebGrease, Version=1.5.1.25624, Culture=neutral, PublicKeyToken=31bf3856ad364e35" oder eine Abhängigkeit davon wurde nicht gefunden. Die gefundene Manifestdefinition der Assembly stimmt nicht mit dem Assemblyverweis überein. (Ausnahme von HRESULT: 0x80131040)
(It says that the assembly "WebGrease, Version 1.5.1.25624" could not be found)
The assembly System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 tried to load the WebGrease assembly and failed.
Solution
I know this issue can be easily bypassed by adding a binding redirect in the web.config like so (since I updated WebGrease):
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.6.5135.21930" />
</dependentAssembly>
Further Question
It would be really nice to know why this is needed and how the *.Optimization assembly is created. The System.Web.Optimization 1.1.3 assembly depends on WebGrease 1.5.2 and a "just take an other version of WebGrease"-redirect could result in method calls, which are not longer existing in the new Version, couldn't it?
Did the developer of *.Optimization include a reference to WebGrease 1.5.2 in their Project, removed the WebGrease assembly after building and created a NuGet package? Or do they load the assembly in code?
Any explanation of how this works is really appreciated. Thank you.