Why is binding redirection required in ASP.NET?

Introduction

Today I updated the ASP.NET MVC application and I encountered the following error (in German - sorry):

Date of publication or assembly "WebGrease, Version = 1.5.1.25624, Culture = neutral, PublicKeyToken = 31bf3856ad364e35" or another abbreviation 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" was not found)

The System.Web.Optimization assembly, Version = 1.1.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35 tried to load the WebGrease assembly and failed.

Decision

I know this problem can be easily circumvented by adding binding redirects to web.config like this (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 very nice to know why this is necessary and how the * .Optimization assembly is created. The assembly of System.Web.Optimization 1.1.3 depends on WebGrease 1.5.2, and the “just take another version of WebGrease” editor can lead to method calls that no longer exist in the new version, right?

Has the * .Optimization developer created a link to WebGrease 1.5.2 in his project, removed the WebGrease assembly after creation, and created the NuGet package? Or do they load the assembly into code?

Any explanation of how this works is really appreciated. Thank.

+4
source share
2

MSDN :

. , , , , .

-... , NuGet work item CodePlex.

+1
  • 1) , , , . ( , ).
    • 1a) , - . , - .
  • 2) Leniel, Nuget. , , , C, A B, B - Nuget - C, A. .
+1

Source: https://habr.com/ru/post/1538203/


All Articles