首页 > 解决方案 > SignalR v1.1.3。升级到服务器 2016 后,在应用启动期间无法解析集线器

问题描述

我的任务是将在 Windows Server 2008 R2 服务器上运行的 Asp.Net MVC4 应用程序迁移到 Windows 2016 服务器。
它在 2008 服务器上按预期工作,但是当我尝试访问 2016 服务器上的站点时,弹出 500 错误说明

[InvalidOperationException: 'NotificationHub' Hub could not be resolved.]
   Microsoft.AspNet.SignalR.Hubs.HubManagerExtensions.EnsureHub(IHubManager hubManager, String hubName, IPerformanceCounter[] counters) +428
   Microsoft.AspNet.SignalR.Infrastructure.ConnectionsManager.GetHubCOntext(String hubName) +295
   RR.DAL.SRepository.<.cctor>b__6() +87
   System.Lazy`1.CreateValue() +734
   System.Lazy`1.LazyInitValue() +189
   RR.MvcApplication.Application_Start() +748

[HttpException (0x80004005): 'NotificationHub' Hub could not be resolved.]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +546
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +171
.....
Version Information: Microsoft .NET Framework Version: 4.0.30319; ASP.NET Version 4.8.4210.0

到目前为止,我在其他问题中发现的内容还没有成功。

我的集线器类被标记为公共
SignalR 路由在其他路由之前添加
我的集线器类与应用程序在同一个程序集中
我已确保我的 Web 配置已配置验证和托管模块

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />

我已经配置了无扩展 URL(从旧服务器结转)
我们的 web.config 目标 4.0<compilation debug="true" targetFramework="4.0" />' 和 iis 上的应用程序池都配置为使用 4.0 .net CLR 版本

我们也在使用 Unity,并且在注册和实例时发生错误使用集线器的类

全球.asax

container.RegisterInstance(typeof(ISRepository), SRepository.Instance, new ContainerControlledLifetimeManager());

SRepository.cs

namespace RR.DAL{
    public class SRepository : ISRepository{

        private readonly static Lazy<SRepository> _instance = new Lazy<SRepository>(() => new SRepository(GlobalHost.ConnectionManager.GetHubContext<NotificationHub>().Clients));

        private SRepository(IHubConnectionContext clients){
            Clients = clients;
        }
        public static SRepository Instance{
            get{ return _instance.Value;}
        }
        private IHubConnectionContext Clients{get;set;}

通知中心.cs

public class NotificationHub: Hub
    {
        private readonly ISRepository _sRepository;

        public NotificationHub(ISRepository sRepository)
        {
            _sRepository = sRepository;
        }

我无法弄清楚为什么应用程序在 app_startup 阶段崩溃。我什至无法查看 /signalr/hubs 页面,它给了我同样的错误。

有任何想法吗?

服务器正在运行带有 .Net Framework 4.6 的 IIS10、Windows Server 2016 该应用程序是 MVC 4 .Net 4.0 并使用 SignalR v1.1.3

标签: c#asp.netiissignalrwindows-server-2016

解决方案


推荐阅读