We are leaving 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=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.
File name: 'Newtonsoft.Json, Version=11.0.0.0, 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?

Thanks!

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 9.0.1.19813. How interesting!

I’m going to do some more digging when time permits. There must be another package sliding in Newtonsoft.Json.dll 9.0.1.19813. 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!