How to fix the 'Could not load file or assembly Newtonsoft.Json, Version=220.127.116.11...' error when creating a REST API Client for Azure in Visual Studio
And in Visual Studio we would have the following projects:
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=18.104.22.168, 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 have temporary removed the Newtonsoft.Json reference from the Business Service project.
I tried again to add the REST API client into the Frontend Service project and everything went as expected.
I installed Newtonsoft.Json again in the Business Service project.
I hope this might help some of you when you face the same error.