Octopus.Client requiring the wrong version of Newtonsoft.Json

Hi,

I’m trying to write a little console application that uses the Octopus.Client library in nuget.org (version 3.1.6, latest in nuget).
This package pulls down Newtonsoft.Json version 6.0.3 as a dependency.

However, when I run the code, it complains by saying that it wants version 7.0.0 of Newtonsoft.Json, which doesn’t exist on nuget.org at all. Here’s the error message:

System.IO.FileLoadException was unhandled
HResult=-2146234304
Message=Could not load file or assembly ‘Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source=Octopus.Client
FileName=Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed

This is similar to another issue here, but closed more than a year ago (https://github.com/OctopusDeploy/Issues/issues/626). Has this issue come back?

Hi William,

Thanks for getting in touch. You’re right, we updated Octopus.Client to require Newtonsoft.Json in Octopus 3.1, but the nuspec file wasn’t updated. I’ve created a GitHub Issue to address this. In the meantime you can work around this by Install-Package Newtonsoft.Json -Version 7.0.1 in your project which should add a BindingRedirect to your *.config file.

The reason that exception mentions Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0 is because the JSON.NET assemblies aren’t versioned the same as the packages, which causes some confusion.

Hope that helps!
Mike