3
votes

I'm using SignalR in an MVC 3.0 Windows Azure application. The following line throws an ArgumentNullException only in the Windows Azure emulator. It doesn't throw if I run the MVC 3.0 application instead of the Cloud application. (I didn't try to run this code in the deployed cloud yet).

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

There's no additional information on the error beside the message Value cannot be null. Parameter name: instanceName. I don't know what instance name is it.

I don't have any idea of what might be wrong. Why would that happen?

EDIT

This is the complete exception info:

System.ArgumentNullException was unhandled HResult=-2147467261
Message=Value cannot be null. Parameter name: instanceName
Source=Microsoft.AspNet.SignalR.Core ParamName=instanceName
StackTrace: at Microsoft.AspNet.SignalR.Hosting.HostDependencyResolverExtensions.InitializeHost(IDependencyResolver resolver, String instanceName, CancellationToken hostShutdownToken) at Owin.OwinExtensions.UseType[T](IAppBuilder builder, Object[] args) at Owin.OwinExtensions.MapHubs(IAppBuilder builder, String path, HubConfiguration configuration) at System.Web.Routing.SignalRRouteExtensions.<>c_DisplayClass7.b_5(IAppBuilder map) at Microsoft.Owin.Host.SystemWeb.OwinAppContext.Initialize(Action1 startup) at Microsoft.Owin.Host.SystemWeb.OwinBuilder.Build(Action1 startup) at System.Web.Routing.RouteCollectionExtensions.MapOwinPath(RouteCollection routes, String name, String pathBase, Action`1 startup) at System.Web.Routing.SignalRRouteExtensions.MapHubs(RouteCollection routes, String name, String path, HubConfiguration configuration) at System.Web.Routing.SignalRRouteExtensions.MapHubs(RouteCollection routes, String path, HubConfiguration configuration) at System.Web.Routing.SignalRRouteExtensions.MapHubs(RouteCollection routes, HubConfiguration configuration) at System.Web.Routing.SignalRRouteExtensions.MapHubs(RouteCollection routes) at Cerebello.MvcApplication.RegisterRoutes(RouteCollection routes) in c:\Projetos\Cerebello\Cerebello\CerebelloWebRole\Global.asax.cs:line 25 at CerebelloWebRole.Code.Helpers.RouteHelper.RegisterAllRoutes() in c:\Projetos\Cerebello\Cerebello\CerebelloWebRole\Code\Helpers\RouteHelper.cs:line 82 at CerebelloWebRole.WebRole.Run() in c:\Projetos\Cerebello\Cerebello\CerebelloWebRole\WebRole.cs:line 23 at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.StartRoleInternal() at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.StartRole() at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.b__2() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:

2
Can you file a bug on github. - davidfowl

2 Answers

3
votes

Unfortunately this is a known issue: https://github.com/SignalR/SignalR/issues/1616

Please feel free to comment on the issue. It is useful to know that this bug occurs in the Windows Azure Emulator. If you find this issue comes up in deployment, that would also definitely be worth noting.

2
votes

It seems that MapHubs() was being called outside the IIS process and it's not allowed now. If you have a method that registers routes and it's shared among code that runs in and outside IIS, you have to make sure that the MapHubs() is only called from whithin IIS.