In this article we will learn How to solve Could not load file or assembly Newtonsoft.Json error.
Recently we face issue in ASP.NET MVC application while serialization/deserialization work on JSON data. I chose to use Json.NET, a very popular JSON framework for .NET. The problem was that when I ran the application, I was getting an exception telling me that the Newtonsoft.Json could not be loaded due to the assembly's manifest definition not matching the assembly reference.
I installed the Newtonsoft.Json library from a NuGet Package on the class library that was used as a business layer. This way, I was separating the business logic from the ASP.NET MVC project that was on the same solution.
The exact error message, the Visual Studio was giving me was this:
System.IO.FileLoadException: 'Could not load file or assembly 'Newtonsoft.Json, Version=10.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)'
- Open NuGet by right-clicking on on the ASP.NET MVC project and select "Manage NuGet Packages" from the context menu.
- After NuGet windows shows up, select the Installed tab.
- A list of installed packages will appear. Locate and select the Newtonsoft.Json.
- Click on the Update button located on the right side of the window as shown below.
Post a Comment