25

I have a reason to use SignalR in Unity, I have decided to go with Microsoft.AspNetCore.SignalR.Client from NuGet.

I've tried a package Nivot.SignalR.Client.Net35 but it uses AspNet.SignalR.Client which is not used anymore, I have created everything I need on my WebApi solution using Microsoft.AspNetCore.SignalR, then I have changed in my Unity project in PlayerSettings Scripting Tuntime Version .NET 4.x Equivalent and Api Compatibility Level to .NET Standard 2.0, which is compatible with AspNetCore.SignalR.Client.

But after I install the package in visual studio while editing scripts and I try to use it Visual Studio keeps calm, but Unity says That the namespace Microsoft.AspNetCore.SignalR.Client doesn't exists. I have read that I have to copy them to a folder in the Assets folder, so I did it, and then Unity said "Unloading broken assembly Assets/Packages/Microsoft.AspNetCore.SignalR.Client.dll, this assembly can cause crashes in the runtime" and it doesn't work.

I've lost my hope. But then I remembered that there is Stackoverflow, so now I hope that someone here can help me. Thanks.

Fabian Domurad
  • 273
  • 1
  • 3
  • 8
  • Could you edit your question and add some paragraphs and other formatting to make it more readable? It looks like a wall of text right now. – Andy Aug 29 '18 at 13:54
  • *"this assembly can cause crashes in the runtime" and it doesn't work"* Crash? Did that happen to you? Can you post the crash log. You have to support such claim with an evidence to get help and that evidence is a crash log. It's also very important that you mention the Unity version in your question. – Programmer Sep 30 '18 at 12:10
  • Have you tried making a clean visual studio project, installing the singalR nuget and building the .dll yourself, then copy the new ddl(s) into an assets/plugin/ folder inside your unity project? This has resolved similiar issues for me in the past as using nuget from inside a unity project tends to mess things up somehow by not correctly linking files – Remy Oct 01 '18 at 12:15
  • If you can provide a project that reproduces the issue, I think we can provide more details. – Tiago Martins Peres Oct 06 '18 at 08:09
  • "I did receive email from a user last year who was using the SignalR client library along with my JSON .NET port. https://www.assetstore.unity3d.com/#/content/11347 " from: https://forum.unity.com/threads/signalr-and-unity3d.226940/ – Tiago Martins Peres Oct 06 '18 at 08:15

2 Answers2

0

You'll have to target .net framework instead of .Net Standard 2.0 in your Unity project because there is no signalr Core out there that targets .Net Standard 2.0 that Unity does. Until Unity updates to 2.2 or 3.0, we're out of luck getting the client side SignalR Core lib working with Unity.

Alternatively, you could try to use a different .net websocket implementation on the client side in Unity.

Chris Bordeman
  • 255
  • 7
  • 19
0

Your error is related to missing dependencies.

Using the latest stable binaries, SignalR client and server both work in Unity3D. You can find the minimum set of DLLs you need here, in the AspNetCore and AspNetCoreClient1.1.0 directories. Include the associated .meta files. Visit this project's settings for proper configuration.

You cannot use nuget in Unity3D correctly, it is too buggy.

DoctorPangloss
  • 2,994
  • 1
  • 18
  • 22