Windows Service PlatformNotSupportedException Windows Server 2012 R2 上的 WCF

WCF on Windows Service PlatformNotSupportedException On Windows Server 2012 R2

我在 Windows 服务中托管 WCF 服务。它适用于 Windows、Windows 7、Windows 8、Windows 10、Windows Server 2016...

的多个版本

但是,在 Windows Server 2012 R2 中它不起作用。

当我尝试启动服务时出现此错误:

Service can not be started. System.PlatformNotSupportedException: This platform does not support operation.
   at System.Net.HttpListener..ctor()
   at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
   at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
   at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
   at System.ServiceModel.Channels.TransportChannelListener.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.HttpChannelListener`1.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channe...

这里是服务代码:

using System;
using System.Configuration;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.ServiceProcess;

namespace WindowsService
{
    public partial class GerenciadorMorphoService : ServiceBase
    {
        private ServiceHost mHost = null;

        public GerenciadorMorphoService()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            if (mHost != null)
            {
                mHost.Close();
            }

            Uri EndPoint = new Uri(ConfigurationManager.AppSettings["EndPointHttp"]);
            mHost = new ServiceHost(typeof(Terminais.Terminal), EndPoint);

            ServiceMetadataBehavior behave = new ServiceMetadataBehavior
            {
                HttpGetEnabled = true
            };

            mHost.Description.Behaviors.Add(behave);

            mHost.Open();
        }

        protected override void OnStop()
        {
            if (mHost != null)
            {
                mHost.Close();
                mHost = null;
            }
        }
    }
}

ConfigurationManager.AppSettings["EndPointHttp"]中的地址是 http://localhost:46125/bioacesso/terminais.svc

防火墙被禁用, 没有应用使用46125端口(我用netstat命令验证过) 我正在使用管理员帐户。

我在这里看到一些这样的帖子:WCF : PlatformNotSupportedException when running Server Projects,

但是,建议的任何解决方案都适用于我的情况,

有人知道会发生什么吗?

我在这个link

中找到了答案

http://www.toughdev.com/content/2017/12/fixing-platformnotsupportedexception-when-running-a-window-communication-foundation-application/

http 驱动程序被禁用,在 windows 2012 中,您只能在注册表中更改它。

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP

开始必须是3(4被禁用)