8

I want to add a RESTful API to my UWP project. But I get the following error in VS2015 when clicking OK in the Add->REST API Client dialog:

Generating client code and adding to project started
Generate client code for REST API with following parameters:
REST API Name: XXXXXX, Base namespace: XXXXXX, Metadata file path: C:\Users\XXXX\AppData\Local\Temp\WebToolsAutoRest\XXXXXX\201612291330467450\swagger.json
Exception: Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0, 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

I found someone facing the same problem here. But it seems he didn't find a solution to this problem. Ant pointers?

Thanks in advance.

Yanbo Chen
  • 93
  • 1
  • 4
  • this is happening for me to. I'm able to reproduce in Xamarin PCL, UWP class libraries, and straight Windows class libraries. VS2015u3, latest Azure SDK – Azure Terraformer Dec 29 '16 at 17:55
  • @emseetea Same in VS2015, latest Azure SDK. – Yanbo Chen Dec 30 '16 at 01:32
  • 1
    The workaround described in the Github issue works for me (copy Newtonsoft.Json.dll from Json.net Nuget version 7.0.1 into the "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE" directory). – RasmusW Dec 30 '16 at 10:05
  • @RasmusW That truly works, thanks a lot. But I met another error after fixing this. I'd rather write one myself now. – Yanbo Chen Dec 30 '16 at 12:00
  • @YanboChen there is also a CLI version of the tool called autorest.exe (https://github.com/Azure/autorest) which you can use to generate the code. I'm not sure if that is affected by the same assembly version problem as the VS extension. – RasmusW Dec 30 '16 at 14:52
  • What if you are trying to generate a rest client for UWP? there are several versions of the Newtonsoft.Json.dll – Azure Terraformer Jan 05 '17 at 06:58
  • @emseetea using the net45 version should work okay - at least, it got me one step closer. Next issue I'm encountering is an issue with installation of nuget package Microsoft.Rest.ClientRuntime 2.3.2 :( – Ade Stringer Feb 09 '17 at 23:23
  • After an error is displayed it generates class files, but is full of compiler errors. Is some library that I'm missing to install? – Mr_LinDowsMac Feb 14 '17 at 16:59

2 Answers2

8

I was seeing the same thing too on vs2015 (I only have 2015 installed though). Apparently the work around is to copy and paste the Newtonsoft.Json.dll into the folder path C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE

I made sure to download the 7.0.1 version using NuGet.

https://github.com/Azure/azure-sdk-for-net/issues/2587

Manny Villa
  • 324
  • 2
  • 4
  • 2
    Newtonsoft.Json in version 7.0.1 - can be found here https://www.nuget.org/api/v2/package/Newtonsoft.Json/7.0.1 . I copied newtonsoft.json.7.0.1.nupkg\lib\net45\ to C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE and Client generation worked again – stefan.seeland Jan 24 '17 at 08:32
  • 1
    I had to restart VS after doing this to make it work. – agileMike Apr 03 '17 at 22:15
0

I ran into this same problem and I'm wondering if it's because I have the Visual Studio 2017 RC installed on the same machine as VS2015.

Here's my workaround. I opened the solution in VS2017 and added the REST API client. Then I closed the solution in VS2017 and re-opened it in VS2015. It's an ugly solution but it seems to work.

benday
  • 1
  • 1