We left Russia. We are against aggression and war with Ukraine. It is a tragedy for our nations, it is a nightmare

Unable to deploy ASP.Net Core solution with Hangfire to Azure AppService -- FileNotFoundException Newtonsoft.Json v11.0.0.0

Salutations everyone,

I have an ASP.Net Core application that deploys perfectly to Azure AppServices and runs like a dream. Hangfire integration worked seamlessly on a local machine, but when the project was deployed to Azure AppServices all the goodness came crashing down.

The website would not start and tossed the vanilla 500.30 error. Upon inspecting the logs the following error message was found to be the culprit:

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.
File name: 'Newtonsoft.Json, Version=, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
   at Hangfire.GlobalConfigurationExtensions.UseRecommendedSerializerSettings
   at Hangfire.GlobalConfigurationExtensions.UseRecommendedSerializerSettings(IGlobalConfiguration configuration)

It appears that Hangfire is hung up on Newtonsoft.Json v11 and doesn’t want to use the installed Newtonsoft.Json v13 that is required by other nuget. Is it possible to configure Hangfire to not be tightly bound to v11?


Hangfire specifies only the minimal version and isn’t bound to any specific one. Any chance that Newtonsoft.Json.dll is missing in the output folder, may be you are using single file deployment or so where additional packages can be truncated from the result?

First off, thanks for your reply Odinserj.

I decided to fire up the Azure AppService debug tools and was able to locate a Newtonsoft.Json.dll file in the wwwroot folder. I downloaded it and checked out the file properties to learn it’s File Version How interesting!

I’m going to do some more digging when time permits. There must be another package sliding in Newtonsoft.Json.dll I’ll update this thread with any more information I come across.

After adding NewtonSoft.Json v13 to every project in the solution and publishing I still get the same error. Not entirely sure what’s happening, but I’ll be moving on to the next green pasture I can find.

Thanks anyways!

Another quick update – this is an Azure DevOps deployment issue, not specifically an issue with Hangfire. The pipeline is not building/deploying the correct NewtonSoft.Json.Dll file.

Thanks for updates Adam!

Just another quick update – MS didn’t help much (big surprise there).

I was able to implement a rather forceful work-around. Imanually added the same version of NewtonSoft.Json to ALL projects in the solution. It’s clearly not elegant or good, but at least I can trigger an Azure DevOps Pipeline to publish the Hangfire-enabled solutiuon to an Azure AppService and not receive an internal server error.

Hm, really strange. From Hangfire’s point of view, Newtonsoft.Json 11.0.1 package is required only for the netstandard2.0 target (for netstandard1.3 it’s 9.0.1, and for net45/net46 it’s 5.0.1 version, please see the Dependencies tab).

And Hangfire.Core for netstandard2.0 requires Newtonsoft.Json of version 11.0.1 simply because it’s the first version that supports netstandard2.0 target. So it’s even not possible for Hangfire.Core to reference earlier Newtonsoft.Json versions for this target.

But I’m not sure regarding the publication process and why it leads to the same error even if you reference version 13.X from all of your projects.

It’s an Azure pipeline thing, not a Hangfire thing. Without my workaround Azure Pipelines includes Newtonsoft.Json v9 in the artifact. I have no idea where it’s getting that from, but Hangfire doesn’t like it.