Signalr1.0.0.0 + unity +实体框架坏了

时间:2013-02-27 16:21:51

标签: asp.net-mvc-4 unity-container entity-framework-5 signalr

今天我从1.0.0alpha2升级到Signalr 1.0.0,我发现我必须更改Application_Start

在:

UnityContainer = Bootstrapper.Initialize();
var unityDependencyResolver = new UnityDependencyResolver(UnityContainer);

DependencyResolver.SetResolver(unityDependencyResolver);

var signalRUnityDependencyResolver = new SignalRUnityDependencyResolver(UnityContainer);

RouteTable.Routes.MapHubs(signalRUnityDependencyResolver);

GlobalHost.DependencyResolver = signalRUnityDependencyResolver;

AreaRegistration.RegisterAllAreas();

现在:

UnityContainer = Bootstrapper.Initialize();
var unityDependencyResolver = new UnityDependencyResolver(UnityContainer);

DependencyResolver.SetResolver(unityDependencyResolver);

var signalRUnityDependencyResolver = new SignalRUnityDependencyResolver(UnityContainer);
//RouteTable.Routes.MapHubs(signalRUnityDependencyResolver);
RouteTable.Routes.MapHubs();

GlobalHost.DependencyResolver = signalRUnityDependencyResolver;

AreaRegistration.RegisterAllAreas();

我知道文档声明RouteTable.Routes.MapHubs();应该先出现,但这只会让一切都挂在那条线上。这是我发现实际加载的唯一方法。

但是当我尝试进行数据库调用时,我没有得到异常或任何东西,但网站将冻结。当我在调试器中点击暂停时,它会在它遇到的第一个EF5查询中被冻结。但也不例外,所有属性都表示为:

Cannot evaluate expression because a native frame is on top of the call stack.

当我删除RouteTable.Routes.MapHubs();时,一切都有效(Signalr除外)。

有时它甚至没有那么远,然后挂起AreaRegistration.RegisterAllAreas();

每次更新Signalr都会再次发生变化,现在让我发疯了。

调用Unity + Signalr工作的正确顺序应该是什么?

修改 在我禁用以下几行之后,它似乎有效:

var signalRUnityDependencyResolver = new SignalRUnityDependencyResolver(UnityContainer);
GlobalHost.DependencyResolver = signalRUnityDependencyResolver;

0 个答案:

没有答案