16 May 2015

Getting Signal/R clients to work on Windows 10 UWP apps

Very recently Windows 10 IoT Core became available – just one of the very exiting technologies Microsoft are cranking out like crazy now. This will enable even the humblest of devices to run Universal Windows Platform apps  Especially in the IoT space technologies like Signal/R are key – to enable devices to quickly exchange and distribute data. Unfortunately, if you add the Microsoft.AspNet.SignalR.Client NuGet package to an UWP and try to connect to a hub, using this code:

var hubConnection = new HubConnection("http://www.microsoft.com");
await hubConnection.Start();

You will run into this error:

An exception of type 'System.IO.FileNotFoundException' occurred in Microsoft.AspNet.SignalR.Client.dll but was not handled in user code

Additional information: Could not load file or assembly 'System.Net, Version=, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The system cannot find the file specified.

And I was not the first one, as can be seen on the Github issues page and this Stackoverflow page.This has nothing to do with Silverlight 5, as is suggested in the comments. Apparently there is some NuGet target mismatch. I don’t quite understand the finer points, but I have found a workaround.

  • I cloned the SignalR repository from Github.
  • When that was done, I opened the Microsoft.AspNet.SignalR.sln using Visual Studio 2015RC.
  • I found the project “Microsoft.AspNet.SignalR.Client.WinRT”. This needed retargeting to Windows 8.1
  • In the configuration manager, I looked for the same project again, and changed the platform from x86 to AnyCPU. For some reason that takes quite some time to complete.


  • Then I built just the Microsoft.AspNet.SignalR.Client.WinRT project – nothing else
  • In the folder <your-root-here>\SignalR\src\Microsoft.AspNet.SignalR.Client.WinRT\bin\Release you will now find a Microsoft.AspNet.SignalR.Client.dll. Copy this file into for instance in a Binaries solution folder in the solution containing the app in which you want to use Signal/R
  • In the app that gave you the “File not found” error, locate the two SignalR references and delete these


  • Now make a reference to the one “Microsoft.AspNet.SignalR.Client.dll” you copied into the Binaries folder
  • Start the app again
  • You will still get an error :), but that’s because there’s no actual Signal/R hub running on www.microsoft.com. If you point this code to a real Signal/R hub, it will work. I have tried on a PC, a Windows 10 mobile phone, and a Raspberry PI2.

Demo solution with both the working (‘”Working”) and non-working app (“Kaputt”)  can be found here. If you don’t feel like repeating all my steps and just want to grab the assembly you need, get it directly from github here.


Unknown said...

SignalR doesn't work on Release Build for Windows 10 (Store Package) :(!

Joost van Schaik said...

Yikes. I have not tried that, just been building (debug) demo stuff. Bummer.