【问题标题】:Remote debugging WCF client application - Can't connect to host远程调试 WCF 客户端应用程序 - 无法连接到主机
【发布时间】:2013-01-05 07:54:54
【问题描述】:

我正在编写一个 WCF 解决方案,其中包含适用于 Windows RT 的移动应用(Windows 应用商店应用)。

当我从开发机器运行移动应用程序时,它运行良好,而 WCF 主机在同一台机器上运行。我试图通过远程调试在我的 MS Surface RT 上对其进行测试。这开始起作用了。该应用程序确实在 Surface 上启动,但是一旦我做一些需要它访问 WCF 主机(在开发机器上运行)的事情,我就会收到以下异常:

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

可能是什么问题?

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

    • 谢谢。大概就是这样。我没有启用它。我这周不在城里,没有专用网络来测试它,但我会在下周末测试它,让你知道它是否有效。
    • 好的,我知道如何在我的笔记本电脑上创建一个私有托管 wifi 网络。添加 privateNetworkClientServer 功能有效!谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-18
    • 1970-01-01
    • 2014-11-29
    • 1970-01-01
    • 2015-02-08
    • 1970-01-01
    相关资源
    最近更新 更多