Windows服务平台上的WCFNoSupportedException在Windows Server 2012 R2上

问题描述 投票:0回答:1

我正在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

但是,任何解决方案都适用于我的案例,

谁知道会发生什么?

c# wcf windows-services windows-server
1个回答
1
投票

我在这个链接中找到了答案

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

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

HKEY_LOCAL_MACHINE \系统\ CurrentControlSet \服务\ HTTP

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

© www.soinside.com 2019 - 2024. All rights reserved.