【问题标题】:WCF on Windows Service PlatformNotSupportedException On Windows Server 2012 R2Windows Server 2012 R2 上的 Windows 服务 PlatformNotSupportedException 上的 WCF
【发布时间】:2019-04-30 17:03:20
【问题描述】:

我在 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】:

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

    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)

    【讨论】:

    • 谢谢你的回答很重要!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-29
    • 1970-01-01
    • 2011-08-25
    • 1970-01-01
    • 2017-09-05
    • 1970-01-01
    相关资源
    最近更新 更多