
我编译了2个不同的WCF“代码项目”示例应用程序,无论我发布的是什么,我都会遇到以下异常,所以我猜我的机器上有一些配置错误:
编辑
我尝试了另一台机器(相同的 *** 作系统,赢得7 64),它工作正常.
我只是无法弄清楚我的电脑上有什么配置错误或丢失.
{"Operation is not supported on this platform."}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.httpChannelListener.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 WCFService.MainForm.startWCFServer() in D:\xxx\MainForm.cs:line 77 下面是代码.我猜没有什么不寻常的基本WCF东西.
private ServiceHost host = null; public voID startWCFServer() { // Create the url that is needed to specify where the service should be tarted urlService = "net.tcp://" + "127.0.0.1" + ":8000/MyService"; // Instruct the ServiceHost that the type that is used is a Servicelibrary.service1 host = new ServiceHost(typeof(Servicelibrary.service1)); host.opening += new EventHandler(host_opening); host.Opened += new EventHandler(host_Opened); host.Closing += new EventHandler(host_Closing); host.Closed += new EventHandler(host_Closed); // The binding is where we can choose what transport layer we want to use. http,TCP ect. NetTcpBinding tcpBinding = new NetTcpBinding(); tcpBinding.TransactionFlow = false; tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign; tcpBinding.Security.Transport.ClIEntCredentialType = TcpClIEntCredentialType.windows; tcpBinding.Security.Mode = SecurityMode.None; // <- Very crucial // Add endpoint host.AddServiceEndpoint(typeof(Servicelibrary.IService1),tcpBinding,urlService); // A channel to describe the service. Used with the proxy scvutil.exe tool ServiceMetadataBehavior MetadataBehavior; MetadataBehavior = host.Description.Behaviors.Find<ServiceMetadataBehavior>(); if (MetadataBehavior == null) { // This is how I create the proxy object that is generated via the svcutil.exe tool MetadataBehavior = new ServiceMetadataBehavior(); //MetadataBehavior.httpGetUrl = new Uri("http://" + _ipAddress.ToString() + ":8001/MyService"); MetadataBehavior.httpGetUrl = new Uri("http://" + "127.0.0.1" + ":8001/MyService"); MetadataBehavior.httpGetEnabled = true; MetadataBehavior.ToString(); host.Description.Behaviors.Add(MetadataBehavior); urlMeta = MetadataBehavior.httpGetUrl.ToString(); } host.open(); // <---- EXCEPTION BLOWS HERE } 细节 :
演示应用程序是here和here并删除了上述相同的异常
它可能是here所述的UAC问题但是这并没有解决我的问题.
*** 作系统是windows 7 x64
提前致谢.
解决方法 这是您无权在给定地址创建服务主机时获得的消息.在您的情况下,您将使用NetTcpBinding获取此信息.以下是一些可能的解决方案 – 您只需要完成它们.>另一个进程是使用相同的绑定 – TCP端口8000(IIS?)>您没有以管理员身份运行VS.NET>未安装windows进程激活服务(WAS)(net.tcp绑定需要windows功能)>未安装windows Communication Foundation http /非HTPP激活(.NET Framework 3.x下的windows功能)>防火墙阻止Net.TCP通信成功.
总结以上是内存溢出为你收集整理的c# – WCF:运行服务器项目时的PlatformNotSupportedException全部内容,希望文章能够帮你解决c# – WCF:运行服务器项目时的PlatformNotSupportedException所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)