自定义ServiceHostFactory从未在Windows Server 2012 R2和IIS 8.5上调用

时间:2022-06-01 18:04:25

I have a WCF Service solution (NET 4) with custom ServiceHostFactory that works fine on my developer machine (Windows 8.1 and IIS 8.5) but I can't get it working on Windows Server 2012 and IIS 8.5 for some reason. The WCF service itself works on Server 2012, but the ServiceHostFactory is never called. Is there a particular module that I should install via Add Roles or Features in Server 2012 in order to make it work?

我有一个WCF服务解决方案(NET 4)与自定义ServiceHostFactory在我的开发人员计算机(Windows 8.1和IIS 8.5)上正常工作,但由于某种原因我无法在Windows Server 2012和IIS 8.5上运行它。 WCF服务本身适用于Server 2012,但从不调用ServiceHostFactory。我是否应该通过Server 2012中的添加角色或功能安装特定模块以使其正常工作?

public class InternalAHostFactory : ServiceHostFactory
{
    protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
    {
        ServiceHost host = base.CreateServiceHost(serviceType, baseAddresses);
        host.Opening += new EventHandler(host_Opening);
        return host;
    }

    void host_Opening(object sender, EventArgs e)
    {
        // This is never called on Windows Server 2012 R2 and IIS 8.5 but works on Windows 8.1 and IIS 8.5
    }

}

1 个解决方案

#1


0  

Adding complete "WCF Services" feature set via the Server Manager solved this issue in my case.

通过服务器管理器添加完整的“WCF服务”功能集解决了我的问题。

#1


0  

Adding complete "WCF Services" feature set via the Server Manager solved this issue in my case.

通过服务器管理器添加完整的“WCF服务”功能集解决了我的问题。