Skip to content

Exception in HubConnectionBuilder.Build using .net5 preview 8 #25259

@comet56us

Description

@comet56us

Describe the bug

I have a working Blazor WASM project (using 3.2) that also uses SignalR to connect to a hub on the server.
When I update to .NET 5 Preview 8, I get an exception when trying to call HubConnectionBuilder.Build.

To Reproduce

I reproduced the same issue by following the instructions here (except creating the project with .NET 5.0 instead of .NET Core 3.1), and trying to run it using Visual Studio.
cc: @guardrex

Exceptions (if any)

Unhandled exception rendering component: Exception has been thrown by the target of an invocation.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.PlatformNotSupportedException: System.Security.Cryptography is not supported on this platform.
   at System.Security.Cryptography.X509Certificates.X509CertificateCollection..ctor()
   at Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionOptions..ctor()
   at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj, Object[] parameters, Boolean wrapExceptions)
   --- End of inner exception stack trace ---
   at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj, Object[] parameters, Boolean wrapExceptions)
   at System.RuntimeType.CreateInstanceMono(Boolean nonPublic, Boolean wrapExceptions)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean skipCheckThis, Boolean fillCache)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions)
   at System.Activator.CreateInstance[HttpConnectionOptions]()
   at Microsoft.Extensions.Options.OptionsFactory`1[[Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionOptions, Microsoft.AspNetCore.Http.Connections.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].CreateInstance(String name)
   at Microsoft.Extensions.Options.OptionsFactory`1[[Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionOptions, Microsoft.AspNetCore.Http.Connections.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].Create(String name)
   at Microsoft.Extensions.Options.OptionsManager`1.<>c__DisplayClass5_0[[Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionOptions, Microsoft.AspNetCore.Http.Connections.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].<Get>b__0()
   at System.Lazy`1[[Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionOptions, Microsoft.AspNetCore.Http.Connections.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1[[Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionOptions, Microsoft.AspNetCore.Http.Connections.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1[[Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionOptions, Microsoft.AspNetCore.Http.Connections.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].CreateValue()
   at System.Lazy`1[[Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionOptions, Microsoft.AspNetCore.Http.Connections.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].get_Value()
   at Microsoft.Extensions.Options.OptionsCache`1[[Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionOptions, Microsoft.AspNetCore.Http.Connections.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].GetOrAdd(String name, Func`1 createOptions)
   at Microsoft.Extensions.Options.OptionsManager`1[[Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionOptions, Microsoft.AspNetCore.Http.Connections.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].Get(String name)
   at Microsoft.Extensions.Options.OptionsManager`1[[Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionOptions, Microsoft.AspNetCore.Http.Connections.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].get_Value()
   at Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionFactory..ctor(IOptions`1 options, ILoggerFactory loggerFactory)
   at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj, Object[] parameters, Boolean wrapExceptions)
   at System.Reflection.RuntimeConstructorInfo.DoInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSiteMain(ServiceCallSite callSite, RuntimeResolverContext argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSite(ServiceCallSite callSite, RuntimeResolverContext argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__1(ServiceProviderEngineScope p)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[IConnectionFactory](IServiceProvider provider)
   at Microsoft.AspNetCore.SignalR.Client.HubConnectionBuilder.Build()
   at test.Client.Pages.Index.OnInitializedAsync()
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()

Further technical details

  • ASP.NET Core Runtime 5.0.0-preview.8.20407.11

  • Include the output of dotnet --info:
    .NET SDK (reflecting any global.json):
    Version: 5.0.100-preview.8.20417.9
    Commit: fc62663a35

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19041
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.100-preview.8.20417.9\

Host (useful for support):
Version: 5.0.0-preview.8.20407.11
Commit: bf456654f9

.NET SDKs installed:
3.1.401 [C:\Program Files\dotnet\sdk]
5.0.100-preview.8.20417.9 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.0-preview.8.20414.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.0-preview.8.20407.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.0-preview.8.20411.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download

  • Visual Studio 16.8 Preview 2

Metadata

Metadata

Assignees

Labels

DoneThis issue has been fixedarea-blazorIncludes: Blazor, Razor Componentsarea-signalrIncludes: SignalR clients and servers

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions