Could not load file or assembly Newtonsoft.Json

John Straumann 0 Reputation points
2024-08-13T22:01:09.2133333+00:00

I have an ASP.NET Web App that I opened today in VS 2022 after some time, and I keep getting an error:

[FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=13.0.3.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. However in the Nuget Package Manager window, I see : Newtonsoft.json, installed: 13.0.3 and in web.config, I see: <dependentAssembly>   <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />  <bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.3.0" /> </dependentAssembly>
I also tried: <dependentAssembly>   <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />  <bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" /> </dependentAssembly>
I have been searching on this for an hour and all results say to check the things I have already checked. Does anyone have any suggestions?    Thanks in advance for any and all help!

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,506 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Lan Huang-MSFT 29,746 Reputation points Microsoft Vendor
    2024-08-14T05:59:30.6033333+00:00

    Hi @John Straumann,

    You are getting this error probably because this assembly does not match the request.

    You can try running the command "Update-Package -reinstall" and cleaning the solution to do a full rebuild.

    Note: To open the PMC in Visual Studio, click Tools -> Nuget Package Manager -> Package Manager Console.

    Or delete the contents of the project's bin folder and rebuild the solution.

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.