【问题标题】:SignalR gives and Error with Unity3D WebGL BuildSignalR 在 Unity3D WebGL 构建中给出错误
【发布时间】:2019-04-30 14:09:29
【问题描述】:

我的 SignalR 连接在 Unity3D 编辑器和 Windows 独立构建中工作,但是当我进行 WebGL 构建时,连接到集线器时出现以下错误。

ArgumentNullException:值不能为空。参数名称:System.String.FormatHelper 处的格式(System.IFormatProvider 提供程序,System.String 格式,System.ParamsArray args)

我还没有找到答案,为什么只有 WebGL 才会发生这种情况,我什至不确定是因为它是 WebGL 还是因为与 Unity 有关。

有没有其他人遇到过这个并知道为什么它只在 WebGL 构建中被抛出。

编辑:添加异常的跟踪

ArgumentNullException: Value cannot be null. Parameter name: format 
at System.String.FormatHelper (System.IFormatProvider provider, System.String format, System.ParamsArray args) [0x00000] in <00000000000000000000000000000000>:0 
at System.String.Format (System.IFormatProvider provider, System.String format, System.Object arg0) [0x00000] in <00000000000000000000000000000000>:0 
at Microsoft.Extensions.DependencyInjection.Resources.FormatNoConstructorMatch (System.Object p0) [0x00000] in <00000000000000000000000000000000>:0 
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite (System.Type serviceType, System.Type implementationType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0 
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact (Microsoft.Extensions.DependencyInjection.ServiceDescriptor descriptor, System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0 
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0 
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00000] in <00000000000000000000000000000000>:0 
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.CreateServiceAccessor (System.Type serviceType) [0x00000] in <00000000000000000000000000000000>:0 
at System.Func`2[T,TResult].Invoke (T arg) [0x00000] in <00000000000000000000000000000000>:0 
at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00000] in <00000000000000000000000000000000>:0 
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope serviceProviderEngineScope) [0x00000] in <00000000000000000000000000000000>:0 
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService (System.Type serviceType) [0x00000] in <00000000000000000000000000000000>:0 
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService (System.Type serviceType) [0x00000] in <00000000000000000000000000000000>:0 
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T] (System.IServiceProvider provider) [0x00000] in <00000000000000000000000000000000>:0 
at Microsoft.AspNetCore.SignalR.Client.HubConnectionBuilder.Build () [0x00000] in <00000000000000000000000000000000>:0 
at PlayerConnection..ctor (System.String hubUrl, System.String access_token) [0x00000] in <00000000000000000000000000000000>:0 
at ConnectionManager.Init (System.String access_token) [0x00000] in <00000000000000000000000000000000>:0 
at SetupManager+<ConnectToHubs>d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0 
at UnityEngine.MonoBehaviour.StartCoroutineManaged2 (System.Collections.IEnumerator enumerator) [0x00000] in <00000000000000000000000000000000>:0 
at UnityEngine.MonoBehaviour.StartCoroutine (System.Collections.IEnumerator routine) [0x00000] in <00000000000000000000000000000000>:0 
at SetupManager+<WaitForAccessToken>d__4.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0 UnityEngine.MonoBehaviour:StartCoroutineManaged2(IEnumerator) UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator) <WaitForAccessToken>d__4:MoveNext() UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) 

(Filename: currently not available on il2cpp Line: -1)

我可以调试 hubUrl 和 access_token 并在调试时打印出它们的值,所以我知道这不是它们造成的。

【问题讨论】:

  • 2019.1 atm 中的 webgl 构建肯定有些奇怪,因为我已经记录并确认了一个错误,即如果您安装 HLAPI,它将无法编译..听到更多内容我不会感到惊讶
  • @BugFinder 我也看到了那个,不得不删除包,我想知道我是否应该安装早期版本并现在进行测试。
  • 这取决于您是否有可能从 HLAPI 包生成 UUID,现在它只是返回 null。
  • 安装最新的 LTS 版本 2017.4.26f1 atm,将对其进行测试并更新您/我的问题
  • 2017.4 与 SignalR 不兼容,因此安装了 2018.3.1 并引发了相同的错误,因此不是 Unity 版本问题。

标签: c# unity3d signalr


【解决方案1】:

好的,经过多次调试并试图解决这个问题,结果证明是线程问题(不是异常表明这一点)。

由于 JavaScript 中缺乏线程支持,Unity 不支持多线程,本质上,System.Threading 命名空间中的任何内容都不受支持,但这是 SignalR 的要求。

Unity 表示他们计划添加多线程支持,但没有确定何时添加的时间框架。

我会把这个留在这里,以防其他人遇到这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-24
    • 2019-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多