Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 25th, 2012  |  syntax: None  |  size: 3.18 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. WCF : PlatformNotSupportedException when running Server Projects
  2. {"Operation is not supported on this platform."}
  3. at System.Net.HttpListener..ctor()
  4. at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
  5. at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
  6. at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
  7. at System.ServiceModel.Channels.HttpChannelListener.OnOpen(TimeSpan timeout)
  8. at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
  9. at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
  10. at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
  11. at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
  12. at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
  13. at WCFService.MainForm.startWCFServer() in D:xxxMainForm.cs:line 77
  14.        
  15. private ServiceHost host = null;
  16.  
  17.     public void startWCFServer()
  18.     {
  19.             // Create the url that is needed to specify where the service should be tarted
  20.             urlService = "net.tcp://" + "127.0.0.1" + ":8000/MyService";
  21.  
  22.             // Instruct the ServiceHost that the type that is used is a ServiceLibrary.service1
  23.             host = new ServiceHost(typeof(ServiceLibrary.service1));
  24.             host.Opening += new EventHandler(host_Opening);
  25.             host.Opened += new EventHandler(host_Opened);
  26.             host.Closing += new EventHandler(host_Closing);
  27.             host.Closed += new EventHandler(host_Closed);
  28.  
  29.             // The binding is where we can choose what transport layer we want to use. HTTP, TCP ect.
  30.             NetTcpBinding tcpBinding = new NetTcpBinding();
  31.             tcpBinding.TransactionFlow = false;
  32.             tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;
  33.             tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
  34.             tcpBinding.Security.Mode = SecurityMode.None; // <- Very crucial
  35.  
  36.             // Add endpoint
  37.             host.AddServiceEndpoint(typeof(ServiceLibrary.IService1), tcpBinding, urlService);
  38.  
  39.             // A channel to describe the service. Used with the proxy scvutil.exe tool
  40.             ServiceMetadataBehavior metadataBehavior;
  41.             metadataBehavior = host.Description.Behaviors.Find<ServiceMetadataBehavior>();
  42.             if (metadataBehavior == null)
  43.             {
  44.                 // This is how I create the proxy object that is generated via the svcutil.exe tool
  45.                 metadataBehavior = new ServiceMetadataBehavior();
  46.                 //metadataBehavior.HttpGetUrl = new Uri("http://" + _ipAddress.ToString() + ":8001/MyService");
  47.                 metadataBehavior.HttpGetUrl = new Uri("http://" + "127.0.0.1" + ":8001/MyService");
  48.                 metadataBehavior.HttpGetEnabled = true;
  49.                 metadataBehavior.ToString();
  50.                 host.Description.Behaviors.Add(metadataBehavior);
  51.                 urlMeta = metadataBehavior.HttpGetUrl.ToString();
  52.             }
  53.  
  54.             host.Open(); // <---- EXCEPTION BLOWS HERE
  55.  
  56.     }
  57.        
  58. host.Description.Behaviors.Add(metadataBehavior);