远程调试WCF客户端应用程序 - 无法连接到主机

时间:2013-01-05 07:54:54

标签: wcf remote-debugging windows-store-apps

我正在撰写包含适用于Windows RT(Windows应用商店应用)的移动应用的WCF解决方案。

当我从开发机器运行它时,移动应用程序工作正常,WCF主机在同一台机器上运行。我尝试通过远程调试在MS Surface RT上测试它。这开始奏效了。应用程序确实在Surface上启动,但是一旦我做了一些需要它来访问WCF主机(在dev机器上运行)的东西,我得到以下异常:

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.

没有内在的例外。 192.168.0.101是开发机器的静态IP。

开发计算机上禁用了Windows防火墙,并且没有其他防火墙。我可以从Surface ping相同的IP地址,所以我知道它可以看到开发机器。

同样,当移动应用程序与WCF主机一起在开发计算机上运行时,这很好用。所以,我不确定问题是什么。

这是在主机中创建端点的代码:

    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();
    }

在客户端:

    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();

问题是什么?

1 个答案:

答案 0 :(得分:0)

您是否在应用程序清单中启用了Private Networks (Client & Server)功能?

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