Could not load file or assembly 'Newtonsoft.Json

Hello,
I am struggling to run Hangfire server after upgrading to Newtonsoft.Json 10.0.2. I will have to use this library as other components are depending on this version.

These are my project configurations.
ASP.Net Core with .Net Framework 4.7
HangFire.SqlServer 1.6.12
Hangfire.AspNetCore 1.6.12

System.IO.FileLoadException: Could not load file or assembly ‘Newtonsoft.Json, Version=4.5.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)
File name: ‘Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’
at Hangfire.Common.JobHelper.ToJson(Object value)
at Hangfire.SqlServer.SqlServerConnection.<>c__DisplayClass14_0.b__0(DbConnection connection)
at Hangfire.SqlServer.SqlServerStorage.<>c__DisplayClass19_0.b__0(DbConnection connection)
at Hangfire.SqlServer.SqlServerStorage.UseConnection[T](Func2 func) at Hangfire.SqlServer.SqlServerStorage.UseConnection(Action1 action)
at Hangfire.SqlServer.SqlServerConnection.AnnounceServer(String serverId, ServerContext context)
at Hangfire.Server.BackgroundProcessingServer.Hangfire.Server.IBackgroundProcess.Execute(BackgroundProcessContext context)
at Hangfire.Server.ServerProcessExtensions.Execute(IServerProcess process, BackgroundProcessContext context)
at Hangfire.Server.AutomaticRetryProcess.Execute(BackgroundProcessContext context)

Can someone help me to resolve this issue?

Hi,

Check if some other project isn´t replace your dll for one the a diferent version.
The problem seems to be with the library version, either you’re the deplying the worng version or you’re using the wrong version on the project refrence.

Looks like a typical issue with Newtonsoft.Json assembly installed into GAC. Try removing it from GAC and see if the problem persists.

I am afraid, this doesn’t work. I have to downgraded to 9.0.1 in order to work.