Developer forum

Forum » Development » Upgrading Solution from 9.13.8 to 9.20.1 - Binding Redirect Issue

Upgrading Solution from 9.13.8 to 9.20.1 - Binding Redirect Issue

Ben Leake
Reply

Hello,

We are in the process of upgrading our highly customized solution from 9.13.8 to 9.20.1 and after quite a bit of fiddling with binding redirects in web.config, I have a mostly working solution in my local environment. However, I'm struggling with a particular 0x80131040 error related to System.Text.Encodings.Web.

Could not load file or assembly 'System.Text.Encodings.Web, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Assembly Load Trace:

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = System.Text.Encodings.Web, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
 (Fully-specified)
LOG: Appbase = file:///C:/Sites/wgo/
LOG: Initial PrivatePath = C:\Sites\wgo\bin
Calling assembly : System.Text.Json, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Sites\wgo\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Text.Encodings.Web, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/0be0ae5a/4beb0713/System.Text.Encodings.Web.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/0be0ae5a/4beb0713/System.Text.Encodings.Web/System.Text.Encodings.Web.DLL.
LOG: Attempting download of new URL file:///C:/Sites/wgo/bin/System.Text.Encodings.Web.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

Stack Trace:

[FileLoadException: Could not load file or assembly 'System.Text.Encodings.Web, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   Dynamicweb.Content.Items.Editors.ItemRelationListMinValidator.RenderValidator(String context, EditFormField field) +0
   Dynamicweb.Admin._Closure$__677-1._Lambda$__0(EditFormField field, Validator v) +51
   Dynamicweb.Controls.Legacy.Renderers.EditFormRenderer.RenderEditFormValidators(EditForm editForm, Action`2 action) +554
   Dynamicweb.Admin.ParagraphEdit.RenderFieldsAndValidators(StringBuilder initialization, EditForm form) +511
   Dynamicweb.Admin.ParagraphEdit.Page_PreRender(Object sender, EventArgs e) +1095
   System.Web.UI.Control.OnPreRender(EventArgs e) +11758920
   System.Web.UI.Control.PreRenderRecursiveInternal() +132
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4000

Running ([system.reflection.assembly]::loadfile("C:\Sites\wgo\bin\System.Text.Encodings.Web.dll")).FullName returns the following string: 

System.Text.Encodings.Web, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51

Since the error is indicating it is trying to load version 5.0.0.0, I added the following binding redirect to web.config:

      <dependentAssembly>
        <assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2dddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>

After restarting the server/app pool it still doesn't recognize the redirect. I added the dll to the GAC, but it didn't seem to make a difference. I also tried cleaning the solution. One other thing to note is that when viewing the logs in the Assembly Binding Log Viewer, it appears it's trying to load both version 5.0.0.0 and 6.0.0.0, even after deleting Temporary ASP.NET Files.

Any help would be much appreciated!

Regards,

Ben


Replies

 
Ben Leake
Reply

A colleague came to my aid here- I simply had a typo in my publicKeyToken for the binding redirect, causing it to be ignored completely. Despite my embarrassment over missing such a simple thing, I'll leave this post up in case anyone else can glean anything helpful from it. :)

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Ben

No worries - we have all been there many times :-)

BR Nicolai

 

You must be logged in to post in the forum