简体   繁体   English

Windows Server 2012 R2上Windows Service Platform上的WCFNotSupportedException

[英]WCF on Windows Service PlatformNotSupportedException On Windows Server 2012 R2

I'm hosting a WCF service in an Windows Service. 我在Windows服务中托管WCF服务。 It works in several versions of Windows, Windows 7, Windows 8, Windows 10, Windows Server 2016... 它适用于Windows,Windows 7,Windows 8,Windows 10,Windows Server 2016的多个版本。

However, in Windows Server 2012 R2 it doesn't work. 但是,在Windows Server 2012 R2中不起作用。

When I try to start the service I get this error: 当我尝试启动服务时,出现此错误:

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...

Here is the service code: 服务代码如下:

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;
            }
        }
    }
}

The address in ConfigurationManager.AppSettings["EndPointHttp"] is http://localhost:46125/bioacesso/terminais.svc ConfigurationManager.AppSettings [“ EndPointHttp”]中的地址为http:// localhost:46125 / bioacesso / terminais.svc

The firewall is disabled, There is no application using the port 46125 (I verified with the netstat command) I am using the Administrator account. 防火墙被禁用,没有使用端口46125的应用程序(我已通过netstat命令验证),我正在使用管理员帐户。

I saw some posts here like this: WCF : PlatformNotSupportedException when running Server Projects , 我在这里看到了一些这样的帖子: WCF:运行Server Projects时PlatformNotSupportedException

however, any solution suggested worked for my case, 但是,任何建议的解决方案都适合我的情况,

Anybody knows what can be happening? 有人知道会发生什么吗?

I found the answer in this link 我在此链接中找到了答案

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

The http driver was disabled, and in the windows 2012 you can only change that in the registry. http驱动程序已禁用,在Windows 2012中,您只能在注册表中进行更改。

HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\HTTP HKEY_LOCAL_MACHINE \\系统\\ CurrentControlSet \\服务\\ HTTP

The key Start has to be 3 (4 is disabled) 启动键必须为3(已禁用4)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Windows Server 2012 R2上的意外崩溃WCF服务 - Unexpected crash WCF Service on Windows Server 2012 R2 Windows Server 2012 r2 中的波斯文化 - Persian culture in Windows Server 2012 r2 如何使Windows服务从Windows Server 2012 R2中的UI运行 - How to make windows service run from the UI in windows server 2012 R2 从Excel读取Windows Server 2012 R2上的.net Windows服务 - .net Windows service on windows server 2012 R2 read from excel 在 Windows Server 2012 R2 中运行针对 .net framework 1.0 构建的 Windows 服务 - Running Windows service built against .net framework 1.0 in Windows Server 2012 R2 WCF 服务适用于 Server 2012 R2,但在 2016 上引发错误 - WCF Service works on Server 2012 R2 but throws error on 2016 在 Windows Server 2012 R2 上构建的应用程序在 Windows Server 2008 R2 上失败 - Application built on Windows Server 2012 R2 fails on windows server 2008 R2 Active Directory中的用户身份验证-Windows Server 2012 R2 - User Authentication in Active Directory - Windows Server 2012 R2 在Windows Server 2012 R2上发送http / 2请求 - send http/2 request on windows server 2012 R2 无法在 Windows 2012 R2 服务器上加载 DLL“tensorflow” - Unable to load DLL 'tensorflow' on Windows 2012 R2 Server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM