'Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies

0

We implemented Azure Keyvault and MSAL authentication in one of our asp.net web forms application. Whereas MSAL is working as expected after installing all owin secirity packages and newtonsoft json package is upgraded from 6.0.0.0 to 10.0.0 version. But while fetching secrets from keyvault, application is encountered with following newtonsoft.json dll missing error.

System.IO.FileLoadException: 'Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'

FusionLog: === Pre-bind state information === LOG: DisplayName = Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed (Fully-specified) LOG: Appbase = file:///C:/Users/v-tukar/source/repos/DWS-CPM-PLG-ETRAX-CoreCode8/Web/Microsoft.IT.eTRAx.UX/ LOG: Initial PrivatePath = C:\Users\v-tukar\source\repos\DWS-CPM-PLG-ETRAX-CoreCode8\Web\Microsoft.IT.eTRAx.UX\bin Calling assembly : Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.

LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Users\v-tukar\source\repos\DWS-CPM-PLG-ETRAX-CoreCode8\Web\Microsoft.IT.eTRAx.UX\web.config LOG: Using host configuration file: C:\Users\v-tukar\Documents\IISExpress\config\aspnet.config LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Post-policy reference: Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed LOG: Attempting download of new URL file:///C:/Users/v-tukar/AppData/Local/Temp/Temporary ASP.NET Files/vs/27ddedce/76380321/Newtonsoft.Json.DLL. LOG: Attempting download of new URL file:///C:/Users/v-tukar/AppData/Local/Temp/Temporary ASP.NET Files/vs/27ddedce/76380321/Newtonsoft.Json/Newtonsoft.Json.DLL. LOG: Attempting download of new URL file:///C:/Users/v-tukar/source/repos/DWS-CPM-PLG-ETRAX-CoreCode8/Web/Microsoft.IT.eTRAx.UX/bin/Newtonsoft.Json.DLL. WRN: Comparing the assembly name resulted in the mismatch: Major Version ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

Note: 1.We have upgraded all keyvault related dll's to latest version(Microsoft.Rest.ClientRuntime.Azure to Version=3.3.18 and Microsoft.Rest.ClientRuntime to 2.3.17) 2.We could see upgraded dll versions in web.config and packages.config file. Also we have checked if any other dll's in the project are dependent on Newtonsoft.Json 6.0.0.0 version dll but we could not find any.

Still we are encountering Newtonsoft.Json dll 6.0.0.0 version error. It will very helpful if anybody could suggest a solution on this

c#
asp.net
json
.net
azure
asked on Stack Overflow Oct 19, 2020 by tulasi karnati

1 Answer

0

Okay, the thing here is, you are using Newtonsoft.json in 3 Nugets in your project -

  • Version 2.3.17 of this:

    enter image description here

  • Version 3.3.18 of this:

    enter image description here

  • Version 4.1.1 (I guess, as you have not mentioned)

    enter image description here

AFAIK, there can be 2 possible solutions to this:

  1. Upgrade Microsoft.Rest.ClientRuntime to 2.3.22 and Microsoft.Rest.ClientRuntime.Azure to 3.3.19.
  2. Change version of Newtonsoft.json to <package id="Newtonsoft.Json" version="10.0.1" targetFramework="net472" /> in packages.json.

Let me know if any issues.

answered on Stack Overflow Oct 19, 2020 by singhh-msft

User contributions licensed under CC BY-SA 3.0