我很抱歉太過於模糊,如果您需要任何精度,我會盡我所能給它。WCF:PlatformNotSupportedException當運行服務器項目
我整理了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
在此先感謝。
您是否擁有Windows Communication Foundation HTTP/Non-HTTP Activation窗口功能?這些選項位於控制面板 - >程序和功能 - >打開或關閉Windows功能 - > Microsoft .NET Framework 3.x(剛剛意識到您的示例是.NET 3.5而不是.NET 4) – SliverNinja