System.IO.FileNotFoundException 在 Windows Phone 8 中运行 TCP 套接



我正在尝试运行如何创建和使用适用于 Windows Phone 的 TCP 套接字客户端应用程序,但收到以下错误......

An exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
An exception of type 'System.Net.Sockets.SocketException' occurred in System.Net.ni.dll and wasn't handled before a managed/native boundary
An exception of type 'System.Net.Sockets.SocketException' occurred in System.Net.ni.dll and wasn't handled before a managed/native boundary
An exception of type 'System.Net.Sockets.SocketException' occurred in System.Net.ni.dll and wasn't handled before a managed/native boundary
An exception of type 'System.Net.Sockets.SocketException' occurred in System.Net.ni.dll and wasn't handled before a managed/native boundary

我的开发计算机上运行了简单 IP 服务,调试时手机通过 USB 链接。它没有在文章中建议您应该使用什么作为 IP 地址从手机访问开发计算机 - 我已经尝试过,

192.168.1.66 // Dev computer address on lan
whitby       // Dev computer name
127.0.0.1    // Localhost, refers to dev computer or phone?
localhost    // ditto

我也在猜测,如果主机错了,我会收到一条很好的错误消息 - 相反,没有任何内容(即空字符串)从e.SocketError.ToString()回显

我正在使用 Windows Phone 8。

实际上,我已经想通了。我习惯了Windows Phone 7编程,似乎系统库在Windows Phone 8中理所当然地抛出异常 - 应用程序继续运行。

问题是防火墙阻止了简单 IP 服务端口。要使其正常工作,您可以暂时禁用Windows防火墙:

    在"开始"菜单中键入"防火墙"
  • 以获取"高级安全Windows防火墙"客户端
  • 点击"视窗防火墙属性"
  • 在"私人配置文件"选项卡下,暂时将"防火墙状态"设置为"关闭"

然后使用开发计算机的 IP 进行连接,例如 192.168.1.66(不是本地主机、127.0.0.1 等)

最新更新