【问题标题】:SignalR error: Invocation provides 1 argument(s) but target expects 0SignalR 错误:调用提供 1 个参数,但目标需要 0
【发布时间】:2019-04-08 20:00:43
【问题描述】:

我正在使用带有 angular6 的 signalR 核心并且我正在接收消息,但在控制台中我总是收到此错误。

什么意思?

System.IO.InvalidDataException: Invocation provides 1 argument(s) but target expects 0.
   at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocol.BindArguments(Byte[] input, Int32& offset, IReadOnlyList`1 parameterTypes, IFormatterResolver resolver)
   at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocol.CreateInvocationMessage(Byte[] input, Int32& offset, IInvocationBinder binder, IFormatterResolver resolver)
fail: Microsoft.AspNetCore.SignalR.Client.HubConnection[57]
      Failed to bind arguments received in invocation '(null)' of 'Send'.
System.IO.InvalidDataException: Invocation provides 1 argument(s) but target expects 0.
   at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocol.BindArguments(Byte[] input, Int32& offset, IReadOnlyList`1 parameterTypes, IFormatterResolver resolver)
   at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocol.CreateInvocationMessage(Byte[] input, Int32& offset, IInvocationBinder binder, IFormatterResolver resolver)
warn: Microsoft.AspNetCore.SignalR.Client.HubConnection[14]

【问题讨论】:

  • 请编辑您的问题以包含调用代码,您的错误在调用代码中。从表面上看,您正在调用带有参数的方法,但该方法不需要参数。

标签: javascript c# .net-core signalr


【解决方案1】:

我偶然发现了同样的错误;尽管我的 C# 代码中的 Hub 具有正确数量的参数。

原来我的javascript脚本代码连接到的Hub是错误的。

也就是说,如果您的 javascript 客户端连接到服务器 Hub,则可能会发生此错误

  1. 有方法,但参数个数不匹配或
  2. 没有javascript调用的方法(提示:检查错别字!)

【讨论】:

  • 我遇到了同样的问题,是由拼写错误引起的。奇怪的是信号器没有提供更好的错误信息
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-20
  • 2015-06-23
  • 1970-01-01
  • 2019-03-18
  • 2017-09-15
  • 1970-01-01
相关资源
最近更新 更多