Search code examples
wcfremote-debuggingwindows-store-apps

Remote debugging WCF client application - Can't connect to host


I'm writing a WCF solution that includes a mobile app for Windows RT (Windows Store app).

The mobile app works fine when I run it from the dev machine, with the WCF host running on the same machine. I tried to test it on my MS Surface RT via Remote Debugging. This starts to work. The app does start on the Surface, but as soon as I do something that requires it to access the WCF host (which is running on the dev machine), I get the following exception:

System.ServiceModel.EndpointNotFoundException was unhandled
Message: An unhandled exception of type 'System.ServiceModel.EndpointNotFoundException' occurred in mscorlib.dll
Additional information: There was no endpoint listening at http://192.168.0.101:8000/Service1 that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

There is no inner exception. 192.168.0.101 is the static IP of the dev machine.

The Windows Firewall is disabled on the dev machine, and there are no other firewalls on it. I am able to ping that same IP address from the Surface, so I know it can see the dev machine.

Again, this works just fine when the mobile app is running on the dev machine along with the WCF host. So, I'm not sure what the issue is.

Here's the code where the endpoint is created in the host:

    ServiceHost hostA = null;

    try
    {
        hostA = new ServiceHost(typeof(Service1), new Uri("http://192.168.0.101:8000") );
        hostA.AddServiceEndpoint(typeof(IService1), new BasicHttpBinding(), "Service1");

        hostA.Open();

        Console.WriteLine();
        Console.WriteLine("Host started.  Press Enter to terminate host.");
        Console.ReadLine();

    }
    finally
    {
        if (hostA.State == CommunicationState.Faulted)
            hostA.Abort();
        else
            hostA.Close();
    }

And in the client:

    var myBinding = new BasicHttpBinding();
    var myEndpoint = new EndpointAddress("http://192.168.0.101:8000/Service1");
    var myChannelFactory = new ChannelFactory<ToOrson.IService1>(myBinding, myEndpoint);

    MyService = myChannelFactory.CreateChannel();

What could the problem be?


Solution

  • Do you have the Private Networks (Client & Server) capability enabled in the application manifest?

    <Capabilities>
        <Capability Name="privateNetworkClientServer" />
    </Capabilities>