Simon Mattes
Simon Mattes

Reputation: 5234

Universal Windows Platform and SignalR (Could not load file or assembly 'System.Net, Version=2.0.5.0)

when using the new Universal Windows Platform and a SignalR client (from Nuget) a strange thing happens when you set the network credential.

The following code works flawlessly:

NetworkCredential Connection_Credentials = new NetworkCredential( "Name", "Password" );
Microsoft.AspNet.SignalR.Client.Connection Connection = new Microsoft.AspNet.SignalR.Client.Connection( "http://localhost/Bla" );

However when you assign the NetworkCredential in the following way the runtime crashes even before executing the code:

NetworkCredential Connection_Credentials = new NetworkCredential( "Name", "Password" );
Microsoft.AspNet.SignalR.Client.Connection Connection = new Microsoft.AspNet.SignalR.Client.Connection( "http://localhost/Bla" );
Connection.Credentials = Connection_Credentials;

The error is: "System.IO.FileNotFoundException: Could not load file or assembly 'System.Net, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The system cannot find the file specified.\r\n at UAP2.MainPage.Page_Loaded(Object sender, RoutedEventArgs e)"

Is this an error I can fix myself (I tried doing the same with another project) or is there a problem in the SignalR package (or one of it's dependencies?).
Why would it want to reference 2.0.5.0 of System.Net and not a 4-* version?

Upvotes: 4

Views: 1971

Answers (3)

LocalJoost
LocalJoost

Reputation: 425

it's a bit crude, but I have found a fix/workaround. Basically you have to make sure you use the assembly from the WinRT project in stead of the two that NuGet attaches. See http://dotnetbyexample.blogspot.nl/2015/05/getting-signalr-clients-to-work-on.html for details

Upvotes: 3

Daniel Plaisted
Daniel Plaisted

Reputation: 16744

A workaround for this should be to compile the SignalR client DLL without support for SL5 - targeting .NET 4.5, Windows 8, Windows Phone Silverlight 8, and Windows Phone 8.1, also known as PCL Profile 259.

Upvotes: 0

Roman Mueller
Roman Mueller

Reputation: 348

I don't have the answer to the problem, but I reported an issue about it on GitHub. Hopefully someone will finally look into it.

https://github.com/SignalR/SignalR/issues/3483

Edit:

Did some testing with the source code of SignalR.Client and it crashes in its DefaultHttpHandler(IConnection connection) constructor. Most likely when in System.Net.Http.HttpClientHandler constructor (for which I don't have source code).

Upvotes: 3

Related Questions