bka*_*dol 5 c# portable-class-library signalr xamarin signalr.client
我的 Xamarin 应用程序中遇到一个恼人的错误。该解决方案包含一个 Android 项目和一个可移植类库。在可移植类库中,我有一个类,它使用一种方法与 SignalR 集线器进行通信InitiateConnection
HubConnection conn= new HubConnection(_url);
// Some events will be registrated on the HubConnection here...
if (!string.IsNullOrWhiteSpace(_userName))
{
conn.Credentials = new System.Net.NetworkCredential(_userName, _password);
}
await conn.Start();
Run Code Online (Sandbox Code Playgroud)
一旦我在调试版本中使用上述方法,它就会正常工作并且我正在接收数据。如果在发布版本中调用此方法,则会引发异常。首先是 Xamarin 未处理的异常。按下继续后,我收到以下异常:
System.InvalidOperationException: Server negotiation failed.
Unhandled Exception:
System.InvalidOperationException: Server negotiation failed.
at Microsoft.AspNet.SignalR.Client.Transports.TransportHelper.<GetNegotiationResponse>b__1 (System.String raw) [0x00000] in <filename unknown>:0
at Microsoft.AspNet.SignalR.TaskAsyncHelper+<>c__DisplayClass19`2[System.String,Microsoft.AspNet.SignalR.Client.NegotiationResponse].<Then>b__17 (System.Threading.Tasks.Task`1 t) [0x00000] in <filename unknown>:0
at Microsoft.AspNet.SignalR.TaskAsyncHelper+TaskRunners`2+<>c__DisplayClass3a[System.String,Microsoft.AspNet.SignalR.Client.NegotiationResponse].<RunTask>b__39 (System.Threading.Tasks.Task`1 t) [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0
at Monitoring.Client.MonitorProxy+<InitiateConnection>d__0.MoveNe
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: Server negotiation failed.
at Microsoft.AspNet.SignalR.Client.Transports.TransportHelper.<GetNegotiationResponse>b__1 (System.String raw) [0x00000] in <filename unknown>:0
at Microsoft.AspNet.SignalR.TaskAsyncHelper+<>c__DisplayClass19`2[System.String,Microsoft.AspNet.SignalR.Client.NegotiationResponse].<Then>b__17 (System.Threading.Tasks.Task`1 t) [0x00000] in <filename unknown>:0
at Microsoft.AspNet.SignalR.TaskAsyncHelper+TaskRunners`2+<>c__DisplayClass3a[System.String,Microsoft.AspNet.SignalR.Client.NegotiationResponse].<RunTask>b__39 (System.Threading.Tasks.Task`1 t) [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0
at Monitoring.Client.MonitorProxy+<InitiateConnectio`
Run Code Online (Sandbox Code Playgroud)
方法的最后一行抛出了异常:await conn.Start();
如果我读取任务的 Exception 属性,我会看到与上面相同的错误。NuGet 包和最近发布的 Xamarin 组件都会出现此问题。有谁知道问题是什么?
| 归档时间: |
|
| 查看次数: |
937 次 |
| 最近记录: |