ASP.Net Core UWP SignalR client HubConnectionBuilder.Build crash

451 Views Asked by At

So we encounter a bug we can't figure out how to resolve. We are using signalR (Core) to have the server send data to connected clients. The servier is an API with .Net Core 3.1 and the clients are UWP clients. In debug mode all is working fine, but when we create a release of our client the SignalR connection failed.

Here is the code of the connection :

var connectUrl = await ControllerManager.Instance.GetAsync<string>($"Signalr/connectionurl");
var token = ControllerManager.Instance.EchinoBearerToken;

 _chatHubConnection = new HubConnectionBuilder()
        .WithUrl($"{connectUrl}/signalr/chathub", options => {
            options.AccessTokenProvider = () => Task.FromResult(token);
        })
        .Build();

The error :

Microsoft.AspNetCore.HttpConnections.Client.HttpConnectionOptions on Microsoft.Extensions.Options.OptionsManager [TOptions] violates the constraint of type TOptions
Parameter name : GenericArguments[0[

And here is the stack trace of the fail:

at Internal.Reflection.Execution.ConstraintValidator.EnsureSatisfiesClassConstraints(Type[] typeParameters, Type[] typeArguments, Object definition, SigTypeContext typeContext) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.Reflection.Execution\src\Internal\Reflection\Execution\TypeLoader\ConstraintValidator.cs:line 86
at Internal.Reflection.Execution.ConstraintValidator.EnsureSatisfiesClassConstraints(Type typeDefinition, Type[] typeArguments) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.Reflection.Execution\src\Internal\Reflection\Execution\TypeLoader\ConstraintValidator.cs:line 96
at Internal.Reflection.Execution.ExecutionEnvironmentImplementation.TryGetConstructedGenericTypeForComponents(RuntimeTypeHandle genericTypeDefinitionHandle, RuntimeTypeHandle[] genericTypeArgumentHandles, RuntimeTypeHandle& runtimeTypeHandle) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.Reflection.Execution\src\Internal\Reflection\Execution\ExecutionEnvironmentImplementation.MappingTables.cs:line 356
at System.Reflection.Runtime.TypeInfos.RuntimeConstructedGenericTypeInfo.GetRuntimeTypeHandleIfAny(RuntimeTypeInfo genericTypeDefinition, RuntimeTypeInfo[] genericTypeArguments) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.Reflection.Core\src\System\Reflection\Runtime\General\TypeUnifier.cs:line 419
at System.Reflection.Runtime.TypeInfos.RuntimeConstructedGenericTypeInfo.GetRuntimeConstructedGenericTypeInfo(RuntimeTypeInfo genericTypeDefinition, RuntimeTypeInfo[] genericTypeArguments) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.Reflection.Core\src\System\Reflection\Runtime\General\TypeUnifier.cs:line 388
at System.Reflection.Runtime.TypeInfos.RuntimeTypeInfo.MakeGenericType(Type[] typeArguments) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.Reflection.Core\src\System\Reflection\Runtime\TypeInfos\RuntimeTypeInfo.cs:line 472
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateOpenGeneric(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain, Int32 slot)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateOpenGeneric(Type serviceType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.<>c__DisplayClass7_0.<GetCallSite>b__0(Type type)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(Type serviceType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, Type serviceType, Type implementationType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain, Int32 slot)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Type serviceType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.<>c__DisplayClass7_0.<GetCallSite>b__0(Type type)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(Type serviceType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.CreateServiceAccessor(Type serviceType)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
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[T](IServiceProvider provider)
at Microsoft.AspNetCore.SignalR.Client.HubConnectionBuilder.Build()
at Echino.ClientMicrosoftLibrary.SignalR.ClientMessageService.<InitHub>d__8.MoveNext() in C:\Source\Echino\Echino-branch-Vanilla\Echino.ClientMicrosoftLibrary\SignalR\ClientMessageService.cs:line 52
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\src\System\Runtime\ExceptionServices\ExceptionDispatchInfo.cs:line 63
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\shared\System\Runtime\CompilerServices\TaskAwaiter.cs:line 186
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\shared\System\Runtime\CompilerServices\TaskAwaiter.cs:line 154
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\shared\System\Runtime\CompilerServices\TaskAwaiter.cs:line 125
at System.Runtime.CompilerServices.TaskAwaiter.GetResult() in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\shared\System\Runtime\CompilerServices\TaskAwaiter.cs:line 515
at Echino.ClientMicrosoftLibrary.SignalR.ClientMessageService.<Connect>d__9.MoveNext() in C:\Source\Echino\Echino-branch-Vanilla\Echino.ClientMicrosoftLibrary\SignalR\ClientMessageService.cs:line 123
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\src\System\Runtime\ExceptionServices\ExceptionDispatchInfo.cs:line 63
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\shared\System\Runtime\CompilerServices\TaskAwaiter.cs:line 186
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\shared\System\Runtime\CompilerServices\TaskAwaiter.cs:line 154
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\shared\System\Runtime\CompilerServices\TaskAwaiter.cs:line 125
at System.Runtime.CompilerServices.TaskAwaiter.GetResult() in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\shared\System\Runtime\CompilerServices\TaskAwaiter.cs:line 515
at Echino.ClientMicrosoftUIComponents.Login.LoginController.<>c.<<OnLoaded>b__9_1>d.MoveNext() in C:\Source\Echino\Echino-branch-Vanilla\Echino.ClientMicrosoftUIComponents\Login\LoginController.xaml.cs:line 157
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\src\System\Runtime\ExceptionServices\ExceptionDispatchInfo.cs:line 63
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\shared\System\Runtime\CompilerServices\TaskAwaiter.cs:line 186
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\shared\System\Runtime\CompilerServices\TaskAwaiter.cs:line 154
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\shared\System\Runtime\CompilerServices\TaskAwaiter.cs:line 125
at System.Runtime.CompilerServices.TaskAwaiter.GetResult() in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\shared\System\Runtime\CompilerServices\TaskAwaiter.cs:line 515
at Echino.ClientMicrosoftUIComponents.Login.LoginController.<OnLoaded>d__9.MoveNext() in C:\Source\Echino\Echino-branch-Vanilla\Echino.ClientMicrosoftUIComponents\Login\LoginController.xaml.cs:line 155

The last occurence of our file in the stack trace is the ClientMessageService.cs:line 52. It's the code pasted

The Min version of UWP is Windows 10 Fall Creators Update and the Target version is 1809 build 17763.

Can anyone help us resolve our issue? Feel free to ask for additional informations.

Thanks a lot

0

There are 0 best solutions below