SignalR命名空间冲突?无法使用MapHubs()

时间:2013-03-07 23:30:46

标签: asp.net-mvc .net-4.0 signalr

尝试在我的项目中更新信号器库,突然解决方案无法构建。

我引用了这些人:

Microsoft.AspNet.SignalR.Core.dll
Microsoft.AspNet.SignalR.SystemWeb.dll

我在global.asax中有这个:

using System;
using System.Web;
using System.Web.Routing;

Intellisense看到RouteTable.Routes.MapHubs()来自SignalRRouteExtensions,但仍然破坏了构建。项目是.net 4.0 MVC 3 app。不应该有任何问题。

你们有没有想过为什么会这样?

Error 71 'System.Web.Routing.RouteCollection' does not contain a definition for 'MapHubs' and no extension method 'MapHubs' accepting a first argument of type 'System.Web.Routing.RouteCollection' could be found (are you missing a using directive or an assembly reference?)    Global.asax.cs

2 个答案:

答案 0 :(得分:4)

您是否手动引用SignalR dll而不是通过NuGet进行安装?如果是这样,我建议您确保Microsoft.AspNet.SignalR.SystemWeb.dll的目标是.NET 4.0而不是4.5。 SignalR提供该组件的不同版本。

您可以使用Reflector或ildasm来帮助您。只需查看Manifest中的程序集TargetFrameworkAttribute::.ctor(string),并确保它包含“.NETFramework,Version = v4.0”。

答案 1 :(得分:2)

此外,我发现当使用不稳定的2.0.0-beta版本时,这种情况发生了。当降级到1.1.3然后它工作正常。