WCF:PlatformNotSupportedExceptionwhenrunningaserverproject非常抱歉,我的表述含糊不清,如果您需要任何精确度,我会尽力给出。我编译了2个不同的WCF“代码项目”示例应用程序,无论我发布什么,我都会遇到以下异常,所以我猜我的机器上有一些配置错误:编辑我试过另一台机器(相同的操作系统,win7x64)和它工作正常。我只是无法弄清楚我的计算机上配置错误或丢失的内容。{“此平台不支持操作。”}在System.Net.HttpListener..ctor()在System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallbackselectTransportManagerCallback)在System.ServiceModel.Channels.HttpChannelListener.OnOpen(TimeSpan超时)在System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan超时)在System.ServiceModel.Dispatcher.ChannelDispatcher。在System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan超时)在System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan超时)在System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan超时)在WCFService.MainForm。startWCFServer()inD:xxxMainForm.cs:line77以下是代码。我猜没有什么不寻找常见的基础WCF东西。私人服务主机主机=空;publicvoidstartWCFServer(){//创建指定服务启动位置所需的urlurlService="net.tcp://"+"127.0.0.1"+":8000/MyService";//指示ServiceHost使用的类型是ServiceLibrary.service1host=newServiceHost(typeof(ServiceLibrary.service1));host.Opening+=newEventHandler(host_Opening);host.Opened+=newEventHandler(host_Opened);host.Closing+=newEventHandler(host_Closing);host.Closed+=newEventHandler(host_Closed);//绑定是我们可以选择要使用的传输层的地方。HTTP、TCP等。NetTcpBindingtcpBinding=newNetTcpBinding();tcpBinding.TransactionFlow=false;tcpBinding.Security.Transport.ProtectionLevel=System.Net.Security.ProtectionLevel.EncryptAndSign;tcpBinding.Security.Transport.ClientCredentialType=TcpClientCredentialType.Windows;tcpBinding.Security.Mode=SecurityMode.None;//<-非常关键ial//添加端点host.AddServiceEndpoint(typeof(ServiceLibrary.IService1),tcpBinding,urlService);//描述服务的通道。与代理scvutil.exe工具一起使用ServiceMetadataBehaviormetadataBehavior;metadataBehavior=host.Description.Behaviors.Find();if(metadataBehavior==null){//这就是我创建通过svcutil.exe工具生成的代理对象的方式metadataBehavior=newServiceMetadataBehavior();//metadataBehavior.HttpGetUrl=newUri("http://"+_ipAddress.ToString()+":8001/MyService");metadataBehavior.HttpGetUrl=newUri("http://"+"127.0.0.1"+":8001/MyService");metadataBehavior.HttpGetEnabled=true;metadataBehavior.ToString();host.Description.Behaviors.Add(元数据行为);urlMeta=metadataBehavior.HttpGetUrl.ToString();}host.Open();//<----EXCEPTIONBLOWSHERE}Details:DemoapplicationProgramhereandhere并删除上面的相同异常它可能是UAC问题,如here所述,但这并没有解决我的问题操作系统是Windows7x64在此先感谢.这是您无权在给定地址创建服务主机时收到的消息。在您的情况下,您将使用NetTcpBinding来获取此信息。这里有一些可能的解决方案-你只需要通过它们。另一个进程正在使用相同的绑定-TCP端口8000(IIS?)您没有以管理员身份运行VS.NETWindowsProcessActivationService(WAS)未安装(net.tcp绑定需要Windows功能)WindowsCommunicationFoundation未安装HTTP/非HTTP激活(.NETFramework3.x下的Windows功能)防火墙阻止Net.Tcp的成功通信。我不知道到底发生了什么以及为什么要这样做,但是评论以下行而不是将metadataBehavior添加到host.Description.Behaviors修复了这个问题:host.Description.Behaviors.Add(metadataBehavior);我真的不需要这个功能,所以它可以被压缩,但我仍然想知道为什么这会导致异常......(尤其是在我伙伴的工作站上工作,所以我相信它与"somesettingsomewhere")对其他项目的评论完全相同的行也会使它们工作,所以毫无疑问。根据这个:http://social.msdn.microsoft.com/forums/en-US/wcf/thread/b67d03d9-e2e6-40e6-aa44-2af6ce5a8a38/问题是元数据绑定不是http所以防火墙阻止它。1->打开SQLServer2->右键单击数据库并选择属性3->单击选项(左面板)更改为数据库集合,选择Latin1_General_CI_AITaskConsolidation。以上就是C#学习教程的全部内容:WCF:PlatformNotSupportedExceptionwhenrunningserverprojects。涉及侵权,请点击维权联系管理员删除。如需转载请注明出处:
