Signalr: Getting Error while using Newtonsoft.Json Version 10.0 with Microsoft.AspNet.SignalR.Client Version 2.2.1.0.

Created on 17 May 2017  路  7Comments  路  Source: SignalR/SignalR

Getting Error while using Newtonsoft.Json Version 10.0 with Microsoft.AspNet.SignalR.Client Version 2.2.1.0. I am getting below error while creating new HubConnection in SignalR.

Even I have given the reference of Newtonsoft.Json Version 10.0.0 from Installing Package from Nuget Package Manager.

Exception Message : Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.

StackTrace :
at Microsoft.AspNet.SignalR.Client.Connection..ctor(String url, String queryString)
at Microsoft.AspNet.SignalR.Client.HubConnection..ctor(String url, Boolean useDefaultUrl)
at Microsoft.AspNet.SignalR.Client.HubConnection..ctor(String url)
at MyNamespace.MyClass.ConnectToWebModuleHub()

Fusion Log :
=== Pre-bind state information ===
LOG: DisplayName = Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
(Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/
about:blank
LOG: Initial PrivatePath = NULL

Calling assembly : Microsoft.AspNet.SignalR.Client, Version=2.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.

LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file:
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
LOG: The same bind was seen before, and was failed with hr = 0x80070002.

Most helpful comment

@moozzyk Thanks for reply.

I also have installed SignalR through Nuget Package Manager and right now I have updated my Newtonsoft Json to 6.0.5 version and it is working properly now. So is it true that Microsoft.AspNet.SignalR.Client Version 2.2.1.0 is only compatible with Newtonsoft.Json Version 6.x? As I am using Microsoft.AspNet.SignalR.Core Version 2.2.1.0 with Newtonsoft.Json Version 10.x, though it's working properly, not creating any issue. I am surprised because though I have installed both from Nuget Package Manager, it is searching for Newtonsoft.Json Version 6.0.

All 7 comments

Maybe u should try adding assemblyBinding to your config file.

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
  </dependentAssembly>
</assemblyBinding>

Does it work for u ?

@Thiago-Caramelo Thanks for replying.

Actually I have tried the same before adding this issue here but it did not work for me.

@hardikpatelse - binding redirect should work. If it does not you need to show your project. SignalR client depends on Newtonsoft.Json 6.0.4. Only one version of an assembly can be loaded into an AppDomain and if you installed version 10.x and it gets loaded SignalR cannot find version 6.x it was compiled against. Binding redirects allow using a different version of an assembly that the one that was requested. It seems that in your case this is not happening. I think NuGet should add appropriate binding redirects if needed when installing a package.

@moozzyk Thanks for reply.

I also have installed SignalR through Nuget Package Manager and right now I have updated my Newtonsoft Json to 6.0.5 version and it is working properly now. So is it true that Microsoft.AspNet.SignalR.Client Version 2.2.1.0 is only compatible with Newtonsoft.Json Version 6.x? As I am using Microsoft.AspNet.SignalR.Core Version 2.2.1.0 with Newtonsoft.Json Version 10.x, though it's working properly, not creating any issue. I am surprised because though I have installed both from Nuget Package Manager, it is searching for Newtonsoft.Json Version 6.0.

We don't change major dependency versions in minor releases so we keep depending on Newtonsoft.Json 6.x. Users can (and many do) force using a newer version of a dependency. I have not seen any reports of SignalR 2.x not working with Newtonsoft.Json 9.x or 10.x.

Issue is resolved now by using Assembly Resolve and given the path of NewtonSoft JSON version 10.0.

Hello @hardikpatelse
I have same Issue with FcmSharp and Microsoft.AspNet.SignalR.Client.
FcmSharp use FcmSharp FcmSharp Newtonsoft.Json (>= 12.0.1) and Microsoft.AspNet.SignalR.Client use only newtonsoft.json, version=6.0.0.0.
I want use FcmSharp in my SQL CLR, in CREATE ASSEMBLY show this error.

Assembly 'SqlLibrary' references assembly 'newtonsoft.json, version=6.0.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed.', which is not present in the current database. SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation has failed (reason: 2(The system cannot find the file specified.)). Please load the referenced assembly into the current database and retry your request.

How Assembly Resolve and given the path of NewtonSoft JSON version 12.0?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DOMZE picture DOMZE  路  4Comments

cceraja picture cceraja  路  6Comments

thedutchess picture thedutchess  路  4Comments

SkyWaterXXS picture SkyWaterXXS  路  4Comments

JoergTiedemann picture JoergTiedemann  路  3Comments