Forum Cross Platform with Xamarin

Mac OS X WCF TcpBinding problem


class MainClass { public static void Main(string[] args) { int port; var l = new TcpListener(IPAddress.Loopback, 0); l.Start(); port = ((IPEndPoint)l.LocalEndpoint).Port; l.Stop(); var service = new Service(); var host = new ServiceHost(service); host.AddServiceEndpoint(typeof(IMyService), new NetTcpBinding(), string.Format("net.tcp://localhost/Service:{0}", port)); host.Open(); } } [ServiceContract(Namespace = "http://mytest/service")] public interface IMyService { [OperationContract] void Hello(); } [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, IncludeExceptionDetailInFaults = true)] public class Service : IMyService { public void Hello() { } }

It works fine using MS.Net. Under Mac OSX I get the following exception when trying to open the service host.

System.Net.Sockets.SocketException: Access denied
Error code: 10013

Any idea?


  • Also works well on Windows using the latest Mono.

  • I found the problem... I noticed I was putting the port number at the end of the address instead of after ip. I fixed that and it worked. Somehow it worked on Mono on Windows and MS.Net.

Sign In or Register to comment.