Latest version of Newtonsoft.Json is 4.0.4 and restsharp.nuspec specify it's dependency without a version:
RestSharp 102.5 is compiled against Newtonsoft.Json 4.0.3.
In an application when adding a dependency toward RestSharp 102.5 you will get Newtonsoft.Json is 4.0.4
On a WPF application this works but on a WP7.1 application you will get the following exception
"File or assembly name 'Newtonsoft.Json, Version=126.96.36.199, Culture=neutral, PublicKeyToken=30AD4FE6B2A6AEED', or one of its dependencies, was not found."
Added manually a reference to Newtonsoft.Json 4.0.3 to my WP7 project and now everything works fine again.
Had the same issue and had to manually switch to 4.0.3. There must be an easier way.
Uninstall-Package Newtonsoft.Json -Force
Install-Package Newtonsoft.Json -Version 4.0.3
Yeah it the workaround that I used! As you said it is a workaround and when you face the issue it takes some time identify the real issue !
Updated Json.NET package to latest version (4.0.4) to fix Issue #187.
Do you plan to push an updated package to Nuget? We're using Selenium.Webdriver that depends on Newtonsoft.Json 4.0.4. Just now, the rest-client cannot load since it tries to look for v4.0.3 of Newtonsoft.Json.
updated JSON.NET to 4.0.5 to fix issue #187
Here is a full dump of the exception message as I found it.
System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=188.8.131.52, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
File name: 'Newtonsoft.Json, Version=184.108.40.206, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
at RestSharp.Deserializers.JsonDeserializer.Deserialize[T](RestResponse response)
at RestSharp.RestClient.Deserialize[T](IRestRequest request, RestResponse raw)
=== Pre-bind state information ===
LOG: User = NICK-LAPTOP\Nick
LOG: DisplayName = Newtonsoft.Json, Version=220.127.116.11, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
LOG: Appbase = file:///C:/Users/Nick/AppData/Local/Temp/vrldyzmz.0dx
LOG: Initial PrivatePath = NULL
Calling assembly : RestSharp, Version=18.104.22.168, Culture=neutral, PublicKeyToken=null.
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Nick\AppData\Local\Temp\vrldyzmz.0dx\Stripe.Tests.dll.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Newtonsoft.Json, Version=22.214.171.124, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
LOG: Attempting download of new URL file:///C:/Users/Nick/AppData/Local/Temp/vrldyzmz.0dx/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/Users/Nick/AppData/Local/Temp/vrldyzmz.0dx/Newtonsoft.Json/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/Users/Nick/AppData/Local/Temp/vrldyzmz.0dx/Newtonsoft.Json.EXE.
LOG: Attempting download of new URL file:///C:/Users/Nick/AppData/Local/Temp/vrldyzmz.0dx/Newtonsoft.Json/Newtonsoft.Json.EXE.
Here is a more concise workaround that doesn't require you to do anything special to the version you are pulling. Add this to your web.config or app.config.
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="126.96.36.199" />
This will rebind all references to JSON.NET to 188.8.131.52 and you can update this as you upgrade.
Nick, app.config is not supported in Windows Phone, so assembly redirection won't solve the problem... :\
Agreed :) I'm trying to find a way to circunvey it on Windows Phone - if not, guess I'll go ahead and install the previous version!
Just a small addendum, the problem does not confine to Windows Phone, but to the whole Silverlight apps: AFAIK, there is no way to make assembly redirection in Silverlight, so this is a BIG issue for this platform, and to all libraries around there (like RestSharp or the Cimbalino Toolkit) that depend on Json.net :(
Did it recently become signed? This was never a problem before.
I personally experienced this kind of problems a while a go on RestSharp, as you can see here: #171
More than just my pull request, you can fill a lot more issues and pull requests regarding Json.net versions breaking...
This is not a RestSharp issue, so I just added an issue/request on json.net page, please check here:
If you agree with it, please vote and comment and maybe we'll be lucky! :)
just shipped 102.6 built against json.net 4.0.5.
sigh and the problem is back, just did a NuGet install of 102.6 and it seems there is now a Newton 4.0.7 out. I see that Pedro updated the source but that change hasn't made its way into the official Nuget bits.
Windows Phone 7.1 (so Mango)
@johnsheehan the problem is the day after you updated the NuGet JSON.NET was released again. It was released twice within two days. http://nuget.org/packages/Newtonsoft.Json
And because of the strong signing of the library each new version has to have a new RestSharp release. If you want to give somebody else, access we could setup a build server to monitor JSON.NET and produce new builds each time. Or we could just ditch JSON.NET for something less likely to break builds like ServiceStack.Text which is not strongly signed.
I would love to get rid of JSON.NET dependency. If I can do so an make all the current JsonDeserializer tests pass, I will. I don't have any time right now to invest in that though. If someone wants to switch it over to ServiceStack or SimpleJson or something else that won't cause these issues, let's discuss it at http://groups.google.com/group/restsharp
John, why not just add the correct Json dependency version number to the NuGet package? That way, when people install RestSharp thru NuGet, it will always get the correct version of Json.net instead of the latest one...
Check here for NuGet dependencies versioning: http://docs.nuget.org/docs/reference/Versioning
That only works for projects that only use RestSharp, if your project uses two packages on NuGet that relay on JSON.NET you are going to have a conflict if the versions don't match. And you will be right back into this dependency hell again.
If this dependency wasn't the 2nd most popular project on NuGet, I would say go for it and see where the chips fall, but there is a huge chance for conflicts with other projects that use JSON.NET.
True, but right now I'm trying to solve RestSharp problem, then we'll get to the other dependencies... ;)
They seem to be one and the same here.
Good news: according to http://json.codeplex.com/workitem/21995, the next version of Json.net will NOT be strongly signed, at least for the Silverlight bits! :)
102.7 released built against Json.NET 4.0.8. Hopefully this is the last update that needs to be made for this. Download via NuGet or https://github.com/restsharp/RestSharp/downloads