【问题标题】:RouteTable.Routes.MapHubs() throwing ArgumentNullException only in the Windows Azure emulator. Why?RouteTable.Routes.MapHubs() 仅在 Windows Azure 模拟器中引发 ArgumentNullException。为什么?
【发布时间】:2013-03-13 16:00:27
【问题描述】:

我在 MVC 3.0 Windows Azure 应用程序中使用 SignalR。 以下行仅在 Windows Azure 模拟器中引发 ArgumentNullException。如果我运行 MVC 3.0 应用程序而不是云应用程序,它不会抛出。 (我还没有尝试在部署的云中运行此代码)。

public static void RegisterRoutes(RouteCollection routes)
{
    RouteTable.Routes.MapHubs();
    // ...
}

消息Value cannot be null. Parameter name: instanceName 旁边没有关于错误的其他信息。我不知道它是什么实例名称。

我不知道可能出了什么问题。 为什么会这样?

编辑

这是完整的异常信息:

System.ArgumentNullException 未处理 HResult=-2147467261
Message=Value 不能为空。参数名称:instanceName
Source=Microsoft.AspNet.SignalR.Core ParamName=instanceName
堆栈跟踪: 在 Microsoft.AspNet.SignalR.Hosting.HostDependencyResolverExtensions.InitializeHost(IDependencyResolver 解析器、字符串 instanceName、CancellationToken hostShutdownToken) 在 Owin.OwinExtensions.UseType[T](IAppBuilder builder, Object[] args) 在 Owin.OwinExtensions.MapHubs(IAppBuilder 构建器,字符串路径,HubConfiguration 配置) 在 System.Web.Routing.SignalRRouteExtensions.c_DisplayClass7.b_5(IAppBuilder 地图) 在 Microsoft.Owin.Host.SystemWeb.OwinAppContext.Initialize(Action1 startup) at Microsoft.Owin.Host.SystemWeb.OwinBuilder.Build(Action1 启动) 在 System.Web.Routing.RouteCollectionExtensions.MapOwinPath(RouteCollection 路线、字符串名称、字符串路径基础、Action`1 启动) 在 System.Web.Routing.SignalRRouteExtensions.MapHubs(RouteCollection 路由、字符串名称、字符串路径、HubConfiguration 配置) 在 System.Web.Routing.SignalRRouteExtensions.MapHubs(RouteCollection 路由、字符串路径、HubConfiguration 配置) 在 System.Web.Routing.SignalRRouteExtensions.MapHubs(RouteCollection 路由,HubConfiguration 配置) 在 System.Web.Routing.SignalRRouteExtensions.MapHubs(RouteCollection 路线) 在 Cerebello.MvcApplication.RegisterRoutes(RouteCollection routes) 中 c:\Projetos\Cerebello\Cerebello\CerebelloWebRole\Global.asax.cs:line 25 在 CerebelloWebRole.Code.Helpers.RouteHelper.RegisterAllRoutes() 中 c:\Projetos\Cerebello\Cerebello\CerebelloWebRole\Code\Helpers\RouteHelper.cs:line 82 在 c:\Projetos\Cerebello\Cerebello\CerebelloWebRole\WebRole.cs:line 23 中的 CerebelloWebRole.WebRole.Run() 在 Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.StartRoleInternal() 在 Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.StartRole() 在 Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.b__2() 在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext、ContextCallback 回调、对象状态、布尔值 保留SyncCtx) 在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback 回调, 对象状态, Boolean 保留SyncCtx) 在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback 回调,对象状态) 在 System.Threading.ThreadHelper.ThreadStart() InnerException:

【问题讨论】:

  • 你能在github上提交一个bug吗?

标签: .net asp.net-mvc-3 azure signalr


【解决方案1】:

很遗憾,这是一个已知问题:https://github.com/SignalR/SignalR/issues/1616

请随时对问题发表评论。知道此错误发生在 Windows Azure 模拟器中很有用。如果您发现这个问题出现在部署中,那也绝对值得注意。

【讨论】:

  • 感谢您的回复。是否有任何解决方法可以让我停止在模拟器中出现此错误?顺便说一句,我将在部署中对其进行测试。
【解决方案2】:

似乎MapHubs() 在 IIS 进程之外被调用,现在不允许。如果你有一个注册路由的方法并且它在 IIS 内外运行的代码之间共享,你必须确保 MapHubs() 只在 IIS 中被调用。

【讨论】:

    猜你喜欢
    • 2021-07-11
    • 2015-10-12
    • 1970-01-01
    • 1970-01-01
    • 2016-04-06
    • 2011-03-16
    • 1970-01-01
    • 1970-01-01
    • 2013-01-09
    相关资源
    最近更新 更多