Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 499 Vote(s) - 3.44 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0

#1
I am facing the error below


> Could not load file or assembly 'Newtonsoft.Json, Version=7.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)

I could see the below in Web.config

<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>

So I changed it to

<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.1.0" />
</dependentAssembly>

In packeges.config I could see the below entry

But still I am facing the same issue. Please help
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
Reply

#2
most of the time this error happens because of different assemblies are dependent on specific version of some other assembly.

the easiest fix is to update all packages that are dependent to Newtonsoft.Json using the nuget package manager.

it will automatically set all config files in your project.
Reply

#3
A lot of things can go wrong and this error message tells you nothing.

> But still I am facing the same issue.

Maybe the easiest way will be to try and reinstall the package.

Go to **TOOLS > NuGet Package Manager** and Select **Package Manager Console**. Execute the following two commands:

uninstall-package newtonsoft.json -force
install-package newtonsoft.json

If you still get an error after doing this, then what worked for me eventually is that I deleted Json.Net's <dependentAssembly> section from my .config file. Reinstall brings it back if it's not there and apparently you need to delete it. Until there will be a normal solution in the package itself, I'm afraid this manual step is a must. In package manager console again execute:

Update-Package –reinstall Newtonsoft.Json

Also take a look at your [.Net version](

[To see links please register here]

) of the projects in your solution.

This is the [Microsoft solution](

[To see links please register here]

) with unloading the project.
Reply

#4
I got the same error, and fixed it by doing a 'Clean' on my solution. I'm using Newtonsoft.Json in a UWP app.
Reply

#5
Thanks @ekostadinov. I was able to get it working with the solution from @ekostadinov. In my case, the default Web MVC template had NewtonSoft JSON version 6. I had added a class library and to that I installed NewtonSoft JSON version 9 from Nuget package manager.

I tried removing the reference from my Web project, packages config and dependencies, but still I was getting error. Now, I was getting error message saying unable to find Newtonsoft JSON version 6. Initially I was getting error message saying unable to find Newtonsoft JSON version 9.

Then I followed @ekostadinov steps.

uninstall-package newtonsoft.json -force
install-package newtonsoft.json

I got a warning with respect to a dependency in the package manager console mentioning about a dependency with the version of Web.Grease dll. But anyways, it was successful.

Just to double check, I ran the last command mentioned in the above post

Update-Package –reinstall Newtonsoft.Json
It ran without any warnings as well.

Now, I am able to use version 9 in all my projects.
Reply

#6
This can happen if package.config contains 2 same packages name with a different version.

For Example,

<package id="System.Spatial" version="5.6.2" targetFramework="net45" />
<package id="System.Spatial" version="5.6.4" targetFramework="net45" />

Thank You.
Reply

#7
I had the same issue and doing the uninstall and reinstall didn't help. At the time I was trying to install the most current version (10.0.3) of Newtonsoft.Json. I ended up installing the 7.0.1 version and then ran across another article that suggested copying that .dll to :\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE. Which I did.

Started the install REST API process again and then received a different error. When attempting to install Microsoft.Rest.ClientRuntime 2.3.2 it failed. For this, I just went into NuGet and had it install to the project in which I was installed the REST API.

Started the REST API install again and this time it installed.

Oh and if it helps anyone with searches, I was doing the Azure Immersion 02-API App tutorial using VS2015 on Windows Server 2012R2.
Reply

#8
I had the same issue. I followed ekostadinov's forced uninstall/reinstall steps, but needed to add one extra step:

I was upgrading my Solution to Framework 4.5.2. My old Web.Config file had a namespace in the configuration tag.

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

I updated to:

<configuration>

Then the bindingRedirect should work for whatever version of NewtonSoft you are using:

<runtime xmlns="">
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Reply

#9
Well, in my case, there were multiple projects in the solution and each was using different version of `NewtonSoft.json`. I had to go ahead and change the version in each project's `package.config` to match with latest version(Well, it could be any version just that it should be same across the projects). Once all the package.config point to the same version, all I had to do was

`Update-Package –reinstall Newtonsoft.Json`

Now, watch out I also had to manually change the version on web.config assembly entry in one of the projects. but that did the job.
Reply

#10

I had the same issue and I got the exception when I was trying to create MassTransit queues:

"Exception: System.TypeInitializationException: The type initializer for 'MassTransit.Serialization.JsonMessageSerializer' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=12.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)"

Solution that worked for me (after spending couple of days reverting several commits):

- We had a windows service solution that has .Service project and
.XUnitTests project. Both of them were using a common nuget that has
dependency on Newtonsoft.Json.dll. There was no explicit reference to
Newtonsoft.Json nuget package in both projects (but we were using
'using Newtonsoft.Json;' namespace in our classes), so the common
nuget was using version 9 of Newtonsoft.Json by default.
- As soon as I installed the Newtonsoft.Json nuget in both .Service and
.XUnitTests projects, the common nuget package started using the
latest v12 Newtonsoft and that fixed my issue.

Just posting it in here if it saves anyone their valuable time.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through