SignalR icon indicating copy to clipboard operation
SignalR copied to clipboard

Want to run a .net framework 4.x or 3.x client against a asp.net core 2.0 signalr service. possible?

Open juansuerogit opened this issue 8 years ago • 11 comments

Want to run a .net framework 4.x or 3.x client against a asp.net core 2.0 signalr service. possible?

for now my client is a .net framework 4.x or 3.x console app. eventually it will be a DLL i drop into unity3d plugins directory.

Then i can call my methods like so MyNet4ClientClass.MakeSignalrCoreCall(data).

Is this possible? Can .NET 3.x or 4.x talk to asp.net core 2.0 signalr service?

I tried to add the nuget package for Microsoft.AspNetCore.SignalR 1.0.0-alpha2-final but....

"Could not install package 'Microsoft.AspNetCore.SignalR 1.0.0-alpha2-final'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. 0 "

i thought this post was hopeful https://www.rizamarhaban.com/2016/09/13/asp-net-core-signalr-for-windows-10-uwp-app/

in the post the guy talks to signalr code 2.0 from a UWP app the client UWP app uses "Microsoft.AspNet.SignalR.Client": "2.2.1" from nuget

and service which uses Microsoft.AspNetCore.SignalR.Server: 0.2.0-alpha1-22118 obtained from https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json repository

this works its seems because these older SignalR.Server packages still exposes themselves the old signalr way. you can see from the url it exposes at /signalr/hubs

but the new new signalr core changed its protocol sometime so now incompatible.

how can i talk to the new new signalr core from .net framework 4.x or 3.x client ?

juansuerogit avatar Dec 17 '17 15:12 juansuerogit

You can't. See other issues for explanations https://github.com/aspnet/SignalR/issues/985 https://github.com/aspnet/SignalR/issues/883 https://github.com/aspnet/SignalR/issues/713

BrennanConroy avatar Dec 17 '17 18:12 BrennanConroy

So my Hololens is dead in the water when it comes to signalr core :( :( so is my Immersive headset :(

juansuerogit avatar Dec 17 '17 18:12 juansuerogit

You can try to upgrade to .net 4.6.1 or higher and use the ASP.NET Core version of SignalR

BrennanConroy avatar Dec 17 '17 18:12 BrennanConroy

wait are you saying a .net 4.6.1 classic .net framework console app could use the ASP.Net core 2 signalr client library Microsoft.AspNetCore.SignalR.Client ? sorry im new to .NET.

juansuerogit avatar Dec 17 '17 18:12 juansuerogit

We target netstandard2.0, here is some details about that https://github.com/dotnet/standard/blob/master/docs/versions/netstandard2.0.md

In short you can run .NET 4.6.1 apps with packages that target netstandard2.0. For SignalR you'll need both the server and client to be AspNetCore versions

BrennanConroy avatar Dec 17 '17 18:12 BrennanConroy

here is a summary and updates concerning my issue: still struggling...

long story short ..

  1. unity3d allows .net 4.6 dlls. you can used from C# scripts via its plugins directory

  2. as per signalr github post: https://github.com/aspnet/SignalR/issues/1228 "you can run .NET 4.6.1 apps with packages that target netstandard2.0. For SignalR you'll need both the server and client to be AspNetCore versions" I created a .net 4.6.1 dll as a wrapper for the signalr core nugets and imported all the DLLs into unity3d plugins directory.

  3. bringing in the 30+ DLLs into the unity plugins directory only works in the editor but fails when generating the UWP project to ultimately deploy to the hololens. here is a screenshot of SignalR core working in the editor https://drive.google.com/file/d/1CZ7R29fylD5cKphn9jMQAKFFOGoRdwpj/view But when i went to build to generate the UWP project to subsequently deploy the hololens.. that failed. ( the build errors are detailed at the end of this post....)

  4. I then tried to follow the hololens development workaround guidelines in the following link but that didnt work either. http://www.harrysmemo.com/post/148213236737/developing-unity3d-apps-for-uwp-and-hololens

  5. so trying another angle was to remove the DLLs from the plugins directory and comment out code in the unity scripts that use my signalr wrapper to get past the build errors. Then try to bring signalr into the generated UWP project after the build. similar to what was done here: https://www.rizamarhaban.com/2016/09/13/asp-net-core-signalr-for-windows-10-uwp-app/ I also tried this another way by trying to reference my .net 4.6.1 wrapper for the signalr core nugets ( see #1 ) ... that also failed ( build errors detailed at the end of this post ) The reason this worked for Riza was because the Old Signalr Client libraries ( not Signalr Core ), were briefly compatible from a messaging perspective with Signalr Core Service. Since then the Signalr Core Service messaging protocols have evolved and are not backwards compatible detailed here.. https://github.com/aspnet/SignalR/issues/985 https://github.com/aspnet/SignalR/issues/883 https://github.com/aspnet/SignalR/issues/713 ... You can indeed can bring in the old Signalr Client libraries into a generated UWP project as Riza did but not the new SignalrCore libraries that target .NET Standard.

you get a Package restore failed. Rolling back package changes for 'Assembly-CSharp'.

  1. Finally i found a suggestion to "Choosing the Windows 10 Fall Creators Update for both Target and Min version for my UWP app " at https://developercommunity.visualstudio.com/content/problem/93522/uwp-uap10015063-not-compatible-with-net-standard-2.html This just brought a different set of errors ( build errors detailed at the end of this post )

  2. Someone from hololens forum suggested I use a 3rd party download for unity called Best HTTP ( pro edition https://www.assetstore.unity3d.com/en/#!/content/10872 ) . but my wife will kill me if i spend more money as im not working at its 60$ ( already spent $3000 for the hololens dev edition ) and im not sure it will talk to signalr core service. https://forums.hololens.com/discussion/comment/19635#Comment_19635

  3. any ideas of what to try next?

................................................

Links: ive posted my struggles ( and gained insight ) at the following places.

https://holodevelopers.slack.com/ https://forums.hololens.com/discussion/comment/19635#Comment_19635 https://github.com/aspnet/SignalR/issues/1228 https://developercommunity.visualstudio.com/content/problem/93522/uwp-uap10015063-not-compatible-with-net-standard-2.html https://www.rizamarhaban.com/2016/09/13/asp-net-core-signalr-for-windows-10-uwp-app/ http://www.harrysmemo.com/post/148213236737/developing-unity3d-apps-for-uwp-and-hololens https://www.assetstore.unity3d.com/en/#!/content/10872

................................................

build errors from attempt #3:...................

error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\Users\fogbr.nuget\packages\System.Collections.Concurrent\4.0.10\ref\dotnet\System.Collections.Concurrent.dll' and 'C:\org\projects\MRTraining\src\srunity2\Assets\Plugins\System.Collections.Concurrent.dll'. Remove one of the duplicate references. error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\Users\fogbr.nuget\packages\System.Collections\4.0.10\ref\dotnet\System.Collections.dll' and 'C:\org\projects\MRTraining\src\srunity2\Assets\Plugins\System.Collections.dll'. Remove one of the duplicate references. ..... about 20 errors of the same type here..

UnityException: Failed to run serialization weaver with command "Temp\StagingArea\Data\Managed\msgpack .dll" "-pdb" " .....

UnityException: Failed to run reference rewriter with command --target="Temp\StagingArea\Newtonsoft.Json.dll" Error: method System.String System.Guid::ToString(System.String,System.IFormatProvider) doesn't exist in target framework. It is referenced from Newtonsoft.Json.dll at System.String Newtonsoft.Json.JsonConvert::ToString(System.Guid,System.Char). Error: method `System.Stri

UnityException: Failed to run serialization weaver with command "Temp\StagingArea\Data\Managed\Microsoft.AspNetCore.SignalR.Common.dll" "-pdb" " Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'

UnityException: Failed to run reference rewriter with command --target="Temp\StagingArea\System.Diagnostics.Tracing.dll" --additionalreferences="Temp\StagingArea"," Error: type System.Diagnostics.Tracing.EventDataAttribute doesn't exist in target framework. It is referenced from System.Diagnostics.Tracing.dll at System.Diagnostics.Tracing.EventCounterPayload. Error: method `System.Void System.Diagnostics.Tracing.EventDataA

Reference Rewriter found some errors while running with command --target="Temp\StagingArea\Microsoft.Extensions.DependencyInjection.Abstractions.dll" -- Error: type System.IServiceProvider doesn't exist in target framework. It is referenced from Microsoft.Extensions.DependencyInjection.Abstractions.dll at System.Object Microsoft.Extensions.DependencyInjection.ActivatorUtilities::Crea multiple errors from this one about 15.......

UnityException: Failed to run reference rewriter with command --target="Temp\StagingArea\System.Runtime.dll" Catastrophic failure while running rrw: System.ArgumentException: Member 'System.Byte' is declared in another module and needs to be imported at Mono.Cecil.MetadataBuilder.LookupToken(IMetadataTokenProvider provider) in c:\u\cecil\Mono.Cecil\AssemblyWriter.cs:line 2227

...................................................................

build errors from attempt #5:...................

Restoring packages for C:\org\projects\MRTraining\src\srunity2\App\GeneratedProjects\UWP\Assembly-CSharp\project.json... Package Microsoft.AspNetCore.SignalR.Client 1.0.0-alpha2-final is not compatible with uap10.0.10240 (UAP,Version=v10.0.10240). Package Microsoft.AspNetCore.SignalR.Client 1.0.0-alpha2-final supports: netstandard2.0 (.NETStandard,Version=v2.0) Package Microsoft.AspNetCore.SignalR.Client 1.0.0-alpha2-final is not compatible with uap10.0.10240 (UAP,Version=v10.0.10240) / win10-arm. Package Microsoft.AspNetCore.SignalR.Client 1.0.0-alpha2-final supports: netstandard2.0 (.NETStandard,Version=v2.0) Package Microsoft.AspNetCore.SignalR.Client 1.0.0-alpha2-final is not compatible with uap10.0.10240 (UAP,Version=v10.0.10240) / win10-arm-aot. Package Microsoft.AspNetCore.SignalR.Client 1.0.0-alpha2-final supports: netstandard2.0 (.NETStandard,Version=v2.0) Package Microsoft.AspNetCore.SignalR.Client 1.0.0-alpha2-final is not compatible with uap10.0.10240 (UAP,Version=v10.0.10240) / win10-x64. Package Microsoft.AspNetCore.SignalR.Client 1.0.0-alpha2-final supports: netstandard2.0 (.NETStandard,Version=v2.0) Package Microsoft.AspNetCore.SignalR.Client 1.0.0-alpha2-final is not compatible with uap10.0.10240 (UAP,Version=v10.0.10240) / win10-x64-aot. Package Microsoft.AspNetCore.SignalR.Client 1.0.0-alpha2-final supports: netstandard2.0 (.NETStandard,Version=v2.0) Package Microsoft.AspNetCore.SignalR.Client 1.0.0-alpha2-final is not compatible with uap10.0.10240 (UAP,Version=v10.0.10240) / win10-x86. Package Microsoft.AspNetCore.SignalR.Client 1.0.0-alpha2-final supports: netstandard2.0 (.NETStandard,Version=v2.0) Package Microsoft.AspNetCore.SignalR.Client 1.0.0-alpha2-final is not compatible with uap10.0.10240 (UAP,Version=v10.0.10240) / win10-x86-aot. Package Microsoft.AspNetCore.SignalR.Client 1.0.0-alpha2-final supports: netstandard2.0 (.NETStandard,Version=v2.0) Package restore failed. Rolling back package changes for 'Assembly-CSharp'.

...................................................................

build errors from attempt #6:..................

Detected package version outside of dependency constraint: Microsoft.NETCore.Runtime.Native 1.0.0 requires System.Diagnostics.Contracts (= 4.0.0) but version System.Diagnostics.Contracts 4.3.0 was resolved. Detected package version outside of dependency constraint: Microsoft.NETCore.Runtime.CoreCLR-x64 1.0.0 requires System.Diagnostics.Contracts (= 4.0.0) but version System.Diagnostics.Contracts 4.3.0 was resolved. Detected package version outside of dependency constraint: Microsoft.NETCore.Runtime.CoreCLR-x86 1.0.0 requires System.Diagnostics.Contracts (= 4.0.0) but version System.Diagnostics.Contracts 4.3.0 was resolved. Version conflict detected for System.Collections. Reference the package directly from the project to resolve this issue. Assembly-CSharp -> Microsoft.AspNetCore.SignalR.Client 1.0.0-alpha2-final -> Microsoft.AspNetCore.SignalR.Client.Core 1.0.0-alpha2-final -> Microsoft.AspNetCore.Sockets.Abstractions 1.0.0-alpha2-final -> System.Threading.Tasks.Channels 0.1.0-alpha-001 -> NETStandard.Library 1.6.1 -> System.Collections (>= 4.3.0) Assembly-CSharp -> Microsoft.NETCore.UniversalWindowsPlatform 5.0.0 -> Microsoft.NETCore.Runtime 1.0.0 -> Microsoft.NETCore.Runtime.CoreCLR-arm 1.0.0 -> System.Collections (= 4.0.10). System.Reflection.Emit.ILGeneration 4.3.0 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on UAP,Version=v10.0.16299, but there is no run-time assembly compatible with win10-arm-aot. System.Reflection.Emit.ILGeneration 4.3.0 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on UAP,Version=v10.0.16299, but there is no run-time assembly compatible with win10-x64-aot. System.Reflection.Emit.ILGeneration 4.3.0 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on UAP,Version=v10.0.16299, but there is no run-time assembly compatible with win10-x86-aot. Package restore failed. Rolling back package changes for 'Assembly-CSharp'. Time Elapsed: 00:00:03.5229975 ========== Finished ==========

juansuerogit avatar Dec 18 '17 20:12 juansuerogit

Fyi ... the BestHttp Unity Asset from Asset Store doesnt connect to Signalr Core https://www.assetstore.unity3d.com/en/#!/content/10872 I got beat for $60 hoping it would work. Here is the difference....

Here is what regular Signalr package references look like. (BestHttp Unity Asset) Server: PackageReference Include="Microsoft.AspNet.SignalR" Version="2.2.2" Client: PackageReference Include="Microsoft.AspNet.SignalR.Client" Version="2.2.2"

Here is what Core SignalR package references look like. Server: PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.0.0-alpha2-final" Client: PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="1.0.0-alpha2-final"

Here is what regular Signalr client sends: (BestHttp Unity Asset) HTTP/1.1 GET http://192.168.1.4:5005/chat/negotiate?tid=0&_=2566636909&clientProtocol=1.5&connectionData=[%7B%22Name%22:%22ChatHub%22%7D]

Here is what Core SignalR sends: HTTP/1.1 GET http://192.168.1.4:5005/chat?id=f78745aa-d21d-4773-9cba-5e27b1fe7b60

more detail at: https://forums.hololens.com/discussion/comment/19635#Comment_19635

juansuerogit avatar Dec 19 '17 03:12 juansuerogit

im currently stuck at the following errors after i edit the min and max versions in the generated UWP project to target Fall Creators Update. as advised here: https://developercommunity.visualstudio.com/content/problem/93522/uwp-uap10015063-not-compatible-with-net-standard-2.html

Version conflict detected for System.Collections. Reference the package directly from the project to resolve this issue. Assembly-CSharp -> Microsoft.AspNetCore.SignalR.Client 1.0.0-alpha2-final -> Microsoft.AspNetCore.SignalR.Client.Core 1.0.0-alpha2-final -> Microsoft.AspNetCore.Sockets.Abstractions 1.0.0-alpha2-final -> System.Threading.Tasks.Channels 0.1.0-alpha-001 -> NETStandard.Library 1.6.1 -> System.Collections (>= 4.3.0) Assembly-CSharp -> Microsoft.NETCore.UniversalWindowsPlatform 5.0.0 -> Microsoft.NETCore.Runtime 1.0.0 -> Microsoft.NETCore.Runtime.CoreCLR-arm 1.0.0 -> System.Collections (= 4.0.10).

juansuerogit avatar Dec 19 '17 03:12 juansuerogit

What version of Unity are you using? My understanding is that .NET Standard 2.0 support requires 2018.1, which has not yet been released. See https://forum.unity.com/threads/net-standard.451314/ for some more context.

analogrelay avatar Dec 19 '17 17:12 analogrelay

Sorry if I overtake your thread but I'm wondering if you run into this error when you build? Because it seems like our problem is quite similar.

ArgumentException: The Assembly System.Reflection.Emit is referenced by Microsoft.AspNetCore.SignalR.Core ('Assets/Plugins/Microsoft.AspNetCore.SignalR.Core.dll'). But the dll is not allowed to be included or could not be found. UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (System.String assemblyPath, System.Collections.Generic.List1[T] alreadyFoundAssemblies, System.String[] allAssemblyPaths, System.String[] foldersToSearch, System.Collections.Generic.Dictionary2[TKey,TValue] cache, UnityEditor.BuildTarget target) (at C:/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:152) UnityEditor.AssemblyHelper.FindAssembliesReferencedBy (System.String[] paths, System.String[] foldersToSearch, UnityEditor.BuildTarget target) (at C:/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:192) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

scarffy avatar Dec 27 '17 08:12 scarffy

For what I understand @scarffy 2018.1 should run .NET standard 2.0 version but it's a beta so you will experiment a lot of Instability. Remember that .NET 4.6 is on an experimental phase too inside of the releases.

I assume that you're running this version. If not, you'll have to download or wait for the final release to minimize the trouble on your final release of the think that you want to develop.

Take a look to the URL that @anurse shared (https://forum.unity.com/threads/net-standard.451314/) with us, there's a good information about it.

Regards.

Ryujose avatar Dec 27 '17 18:12 Ryujose