How to fix the 'Could not load file or assembly Newtonsoft.Json, Version=' error when creating a REST API Client for Azure in Visual Studio

The last few days I have been experimenting with the different types of App Services that the Azure platform provides. One very interesting combination of app services is a ASP.NET MVC client (Azure Web app) or a WebAPI (Azure API app) which acts as the middleware between a JavaScript client and an internal “business” WebAPI (Azure API app). The architecture looks like this:

An app service architecture

And in Visual Studio we would have the following projects:

An app service architecture in Visual Studio

We might also want to use Swagger for adding metadata information to our WebAPIs. When using Swagger we can save some time by generating the code of a proxy client which is placed in the Frontend service and calls the services of the Business Service project. We can achieve that by adding a new REST API client in the Frontend service. However, when doing this action and at least on Visual Studio 2015 we get the following error:

Generating client code and adding to project started
Generate client code for REST API with following parameters:
REST API Name: XXX, Base namespace: XXX, Metadata file path: C:\...\swagger.json
Exception: Could not load file or assembly 'Newtonsoft.Json, Version=, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
Generating client code and adding to project failed
Adding REST API client for failed

After a quick search I found this solution from StackOverflow, however, it has not worked for me.

Updating the Newtonsoft.Json for all projects in my solution was also no solution.

At the end the following steps worked for me:

I hope this might help some of you when you face the same error.

comments powered by Disqus