WCF: PlatformNotSupportedException when starting server projects

I apologize in advance for being too vague, if you need any kind of accuracy, I will do my best to give it.

I compiled 2 different WCF Code Project application sample applications, and I get the following exception, regardless of what I run, so I think that something is incorrectly configured on my machine:

EDIT
I tried on another machine (Same OS, win 7 64) and it works fine.
I just can't figure out which configuration is wrong or missing on my computer.

{"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 

Below is the code. Nothing unusual, basic WCF stuff, I think.

  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 } 


DETAILS:
Demos here and here and the exception of the same exception described above
It may be a UAC problem, as stated here. But that did not fix my problem.
OS - Windows 7 x64

Thanks in advance.

+4
source share
4 answers

I don’t know exactly what is happening and why, but commenting on the following line and not adding metadataBehavior to host.Description.Behaviors fixes the problem:

  host.Description.Behaviors.Add(metadataBehavior); 

I really don't need this function, so it's fine to compress it, but I'm still wondering why this throws an Exception ... (This especially works on my partner workstation, so I'm sure it needs to be done with " some setting somewhere ")

Commenting out the same type of lines in other projects makes them work, so there is no doubt left.

0
source

This is the message that you receive when you are not allowed to create host services at the specified address. In your case, you get this using NetTcpBinding. Here are some possible solutions for this - you just need to skip them.

  • Another process uses the same binding - TCP port 8000 (IIS?)
  • You are not using VS.NET as an administrator
  • Windows Activation Service (WAS) is not installed (requires Windows feature to bind net.tcp)
  • Windows Communication Foundation HTTP / Non-HTPP Activation Not Installed (Windows Feature in .NET Framework 3.x)
  • The firewall blocks Net.Tcp successful communication.
+2
source

According to this: http://social.msdn.microsoft.com/forums/en-US/wcf/thread/b67d03d9-e2e6-40e6-aa44-2af6ce5a8a38/ the problem is that the metadata binding is not http, so the firewall blocks her.

0
source

1-> Open SQL Server

2-> Right-click the database and select properties

3-> Click options (left panel) in the collection database select Latin1_General_CI_AI

mission testified.

0
source

Source: https://habr.com/ru/post/1379144/


All Articles