I got this exception with SignalR, deployed in Azure WebSites. It works fine in debug environment. It\'s SignalR 1.0.1 and I use .NET MVC and WebApi
The data
For others coming to this page, I had the same issue but the solution was much simpler. As mentioned in comments above, the accepted answer is bad. Also mentioned is that SignalR defaults to use MachineKeyDataProtector for IProtectedData. MapHubs and MapConnection both call a function InitializeProtectedData which registers MachineKeyDataProtector with the dependency resolver.
My problem was that I was mapping my SignalR routes, and THEN configuring the dependency resolver
RouteTable.Routes.MapConnection("SomeEndpoint", "SomeEndpointUrl");
GlobalHost.DependencyResolver =
new StructureMapDependencyResolver(ObjectFactory.Container);
So basically the IProtectedData resolver registration done by MapConnection -> InitializeProtectedData was getting blown away when I registered my custom resolver. Simple fix, set the resolver BEFORE mapping the connection.
GlobalHost.DependencyResolver =
new StructureMapDependencyResolver(ObjectFactory.Container);
RouteTable.Routes.MapConnection("SomeEndpoint", "SomeEndpointUrl");