WCF 服务参考在其他 PC 上不起作用上不、WCF、PC

2023-09-07 08:42:38 作者:烟花→已冷

我有一个 Windows 应用商店 - Metro 应用程序,该应用程序与运行在同一台 PC(托管在控制台应用程序中)但在 Windows 8 的桌面模式上的 Net TCP WCF 服务连接.我在 Metro 应用程序中添加了 WCF 服务的引用和一切正常.

I have a Windows Store - Metro app that connects with a Net TCP WCF Service running on same PC (hosted in a console application) but on Desktop mode of Windows 8. I have added a reference of WCF Service inside metro app and everything works fine.

我打包了我的商店/地铁应用程序和 WCF 服务,并在另一台没有安装 Visual Studio 的 PC 上试用,所以我不重新编译代码,我只安装了地铁应用程序包并运行 WCF 服务的可执行文件.WCF 服务启动正常,但是当我启动我的 Metro 应用程序时它给了我错误(见下图)

I package my store/metro app and WCF Service and try out on another PC which don't have Visual Studio installed so I don't recompile the code, I just install the metro app package and run the executable of WCF Service. WCF Service starts fine but when I launch my metro app it give me error (see the image below)

似乎由于某种原因,安装在其他 PC 上的 Metro 应用程序无法找到服务参考.谷歌搜索后我尝试了很多东西,但没有任何效果.任何想法/提示/建议将不胜感激.

It seems that for some reason metro app when installed on other PC is unable to find the service reference. I have tried many things after googling but nothing works. Any ideas/hint/suggestion would be greatly appreciated.

推荐答案

Windows 应用商店应用程序一般不能使用环回地址,除非 1) SAME 进程内的通信,或 2) 用于开发目的.来自如何启用环回和排除网络隔离故障:

Windows Store Apps generally cannot use the loopback address, except for 1) communication within the SAME process, or 2) for development purposes. From How to enable loopback and troubleshoot network isolation:

使用 IP 环回地址的网络通信不能用于 Windows 应用商店应用中的进程间通信(两个不同应用之间),因为这受到网络隔离的限制.出于通信目的,允许在同一进程内的应用内使用 IP 环回地址进行网络通信.

Network communications using an IP loopback address cannot be used for interprocess communication (between two different apps) in a Windows Store app since this is restricted by network isolation. Network communication using an IP loopback address is allowed within an app within the same process for communication purposes.

开发人员可能希望将环回用于测试或调试目的,即使客户无法使用该功能.例如,应用程序可能希望从 Windows 应用商店应用程序的 Web 服务下载数据.出于开发目的,开发人员希望在单台计算机上测试应用程序,该计算机在 127.0.0.1 上本地配置了 Web 服务.

A developer may want to use loopback for testing or debugging purposes, even though that capability will not be available for customers. For example, an app may want to download data from a web service from a Windows Store app. For development purposes, the developer wants to test the app on a single computer that is configured with the web service locally on 127.0.0.1.

Loopback 仅允许用于开发目的.不允许在 Visual Studio 之外安装的 Windows 应用商店应用使用.

Loopback is permitted only for development purposes. Usage by a Windows Store app installed outside of Visual Studio is not permitted.

在生产场景中,您可能必须在单独的计算机上安装 WCF 服务.请注意,您必须启用专用网络".您的应用程序清单(在客户端应用程序上)中启用本地网络访问的功能.

In a production scenario, you will likely have to install the WCF service on a separate machine. Note that you will have to enable the "private network" capability in your application manifest (on the client app) to enable local network access.