我正在使用Unity 3D创建UWP应用。对于某些在线功能,我正在使用SignalR。由于在应用程序编译后不断出现奇怪的错误,因此我在服务器端实现了一些基本的日志记录功能。
然后我意识到,已编译产品中缺少请求URI的一部分。
这是我在Unity编辑器中调试时服务器收到的内容:
Request: GET
URI: http://192.168.137.1:9000/signalr/negotiate?clientProtocol=2.0&connectionData=[%7B%22Name%22:%22ARHub%22%7D]
Remote Address: 192.168.137.1:53999
Headers: [Connection: keep-alive], [Host: 192.168.137.1:9000], [User-Agent: SignalR.Client.NetStandard/2.4.0.0 (Microsoft Windows NT 10.0.17134.0)]
这是我编译为UWP之后的相同请求。您会看到其中一个标头以及要连接的集线器的名称丢失。
Request: GET
URI: http://192.168.137.1:9000/signalr/negotiate?clientProtocol=2.0&connectionData=[%7B%7D]
Remote Address: 192.168.137.1:52933
Headers: [Host: 192.168.137.1:9000], [User-Agent: SignalR.Client.NetStandard/2.4.0.0 (Microsoft Windows NT 10.0.17134.0)]
这是客户端(UWP应用)上记录的异常:
Error: System.Security.SecurityException: The public key is not valid.
at System.Reflection.AssemblyName.get_FullName () [0x00000] in <00000000000000000000000000000000>:0
at System.AppDomain.LoadSatellite (System.Reflection.AssemblyName assemblyRef, System.Boolean throwOnError) [0x00000] in <00000000000000000000000000000000>:0
at System.Reflection.Assembly.InternalGetSatelliteAssembly (System.String name, System.Globalization.CultureInfo culture, System.Version version, System.Boolean throwOnFileNotFound, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0
at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly (System.Globalization.CultureInfo lookForCulture, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0
at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet (System.Globalization.CultureInfo culture, System.Collections.Generic.Dictionary`2[TKey,TValue] localResourceSets, System.Boolean tryParents, System.Boolean createIfNotExists, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0
at System.Resources.ResourceManager.InternalGetResourceSet (System.Globalization.CultureInfo requestedCulture, System.Boolean createIfNotExists, System.Boolean tryParents, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0
at System.Resources.ResourceManager.InternalGetResourceSet (System.Globalization.CultureInfo culture, System.Boolean createIfNotExists, System.Boolean tryParents) [0x00000] in <00000000000000000000000000000000>:0
at System.Resources.ResourceManager.GetString (System.String name, System.Globalization.CultureInfo culture) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.AspNet.SignalR.Client.HubConnection.OnClosed () [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.AspNet.SignalR.Client.Connection.Disconnect () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.Display+DisplaysUpdatedDelegate.Invoke () [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.AspNet.SignalR.TaskAsyncHelper+<>c__DisplayClass19_1.<ContinueWithNotComplete>b__0 (System.Threading.Tasks.Task t) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.XR.WSA.Sharing.WorldAnchorTransferBatch+SerializationDataAvailableDelegate.Invoke (System.Byte[] data) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.AspNet.SignalR.TaskAsyncHelper+<>c__70`1[T].<RunWithPreservedCulture>b__70_0 (System.Action`1[T] f, T state) [0x00000] in <00000000000000000000000000000000>:0
at System.Comparison`1[T].Invoke (T x, T y) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.AspNet.SignalR.TaskAsyncHelper.RunWithPreservedCulture[T1,T2,TResult] (Microsoft.AspNet.SignalR.TaskAsyncHelper+CulturePair preservedCulture, System.Func`3[T1,T2,TResult] func, T1 arg1, T2 arg2) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.AspNet.SignalR.TaskAsyncHelper.RunWithPreservedCulture[T] (Microsoft.AspNet.SignalR.TaskAsyncHelper+CulturePair preservedCulture, System.Action`1[T] action, T arg) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.AspNet.SignalR.TaskAsyncHelper+<>c__DisplayClass72_0.<ContinueWithPreservedCulture>b__0 (System.Threading.Tasks.Task t) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.XR.WSA.Sharing.WorldAnchorTransferBatch+SerializationDataAvailableDelegate.Invoke (System.Byte[] data) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke () [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.Task.Execute () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.XR.WSA.Sharing.WorldAnchorTransferBatch+SerializationDataAvailableDelegate.Invoke (System.Byte[] data) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.Task.ExecuteWithThreadLocal (System.Threading.Tasks.Task& currentTaskSlot) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.Task.ExecuteEntry (System.Boolean bPreventDoubleExecution) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.ThreadPoolTaskScheduler.TryExecuteTaskInline (System.Threading.Tasks.Task task, System.Boolean taskWasPreviouslyQueued) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.TaskScheduler.TryRunInline (System.Threading.Tasks.Task task, System.Boolean taskWasPreviouslyQueued) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.TaskContinuation.InlineIfPossibleOrElseQueue (System.Threading.Tasks.Task task, System.Boolean needsProtection) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.StandardTaskContinuation.Run (System.Threading.Tasks.Task completedTask, System.Boolean bCanInlineContinuationTask) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.Task`1[TResult].TrySetException (System.Object exceptionObject) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.UnwrapPromise`1[TResult].TrySetFromTask (System.Threading.Tasks.Task task, System.Boolean lookForOce) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.UnwrapPromise`1[TResult].ProcessCompletedOuterTask (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.UnwrapPromise`1[TResult].InvokeCore (System.Threading.Tasks.Task completingTask) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.UnwrapPromise`1[TResult].Invoke (System.Threading.Tasks.Task completingTask) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.Task`1[TResult].TrySetException (System.Object exceptionObject) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.TaskCompletionSource`1[TResult].TrySetException (System.Collections.Generic.IEnumerable`1[T] exceptions) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.AspNet.SignalR.TaskAsyncHelper.SetUnwrappedException[T] (System.Threading.Tasks.TaskCompletionSource`1[TResult] tcs, System.Exception e) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.AspNet.SignalR.TaskAsyncHelper+TaskRunners`2+<>c__DisplayClass3_0[T,TResult].<RunTask>b__0 (System.Threading.Tasks.Task`1[TResult] t) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.XR.WSA.Sharing.WorldAnchorTransferBatch+SerializationDataAvailableDelegate.Invoke (System.Byte[] data) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.AspNet.SignalR.TaskAsyncHelper+<>c__70`1[T].<RunWithPreservedCulture>b__70_0 (System.Action`1[T] f, T state) [0x00000] in <00000000000000000000000000000000>:0
at System.Comparison`1[T].Invoke (T x, T y) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.AspNet.SignalR.TaskAsyncHelper.RunWithPreservedCulture[T1,T2,TResult] (Microsoft.AspNet.SignalR.TaskAsyncHelper+CulturePair preservedCulture, System.Func`3[T1,T2,TResult] func, T1 arg1, T2 arg2) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.AspNet.SignalR.TaskAsyncHelper.RunWithPreservedCulture[T] (Microsoft.AspNet.SignalR.TaskAsyncHelper+CulturePair preservedCulture, System.Action`1[T] action, T arg) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.AspNet.SignalR.TaskAsyncHelper+<>c__DisplayClass73_0`1[T].<ContinueWithPreservedCulture>b__0 (System.Threading.Tasks.Task`1[TResult] t) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.XR.WSA.Sharing.WorldAnchorTransferBatch+SerializationDataAvailableDelegate.Invoke (System.Byte[] data) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.ContinuationTaskFromResultTask`1[TAntecedentResult].InnerInvoke () [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.Task.Execute () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.XR.WSA.Sharing.WorldAnchorTransferBatch+SerializationDataAvailableDelegate.Invoke (System.Byte[] data) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.Task.ExecuteWithThreadLocal (System.Threading.Tasks.Task& currentTaskSlot) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.Task.ExecuteEntry (System.Boolean bPreventDoubleExecution) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00000] in <00000000000000000000000000000000>:0
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <00000000000000000000000000000000>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.InteropServices.ComCompatibleVersionAttribute..ctor (System.Int32 major, System.Int32 minor, System.Int32 build, System.Int32 revision) [0x00000] in <00000000000000000000000000000000>:0
at Assets.Scripts.Controllers.SignalRControllerBehaviour.remove_ShowDevicesRequested (System.EventHandler`1[TEventArgs] value) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.XR.WSA.Sharing.WorldAnchorTransferBatch+SerializationDataAvailableDelegate.Invoke (System.Byte[] data) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.Display+DisplaysUpdatedDelegate.Invoke () [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation+<>c.<.cctor>b__7_0 (System.Object state) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.XR.WSA.Sharing.WorldAnchorTransferBatch+SerializationDataAvailableDelegate.Invoke (System.Byte[] data) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.UnitySynchronizationContext.Exec () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.UnitySynchronizationContext.ExecuteTasks () [0x00000] in <00000000000000000000000000000000>:0
谁能告诉我为什么会发生这种情况,更重要的是,我该如何解决?
也(我不确定这是否相关),这些实际上都是零,我没有进行任何更改。应该没有适当的地址吗?
编辑
这是客户端上的相关代码部分:
[...]
_connection = new HubConnection(url);
_connection.TraceLevel = TraceLevels.All;
_connection.TraceWriter = connectionTraceWriter;
_proxy = _connection.CreateHubProxy("ARHub");
// subscribe to proxy and connection events
await _connection.Start();
[...]