在Windows Phone 8中运行TCP Socket客户端教程时出现System.IO.FileNotFoundException

时间:2013-10-03 11:08:24

标签: sockets windows-phone-8

我正在尝试运行How to create and use a TCP socket client app for Windows Phone,但会收到以下错误...

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。

1 个答案:

答案 0 :(得分:0)

实际上,我已经弄明白了。我习惯了Windows Phone 7编程,看起来系统库在Windows Phone 8中当然会抛出异常 - 应用程序继续运行。

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

  • 在“开始”菜单中键入“防火墙”以获取“具有高级安全性的Windows防火墙”客户端
  • 点击“Windows防火墙属性”
  • 在“私人资料”标签下,暂时将“防火墙状态”设置为“关闭”

然后使用开发计算机的IP连接,例如192.168.1.66(不是localhost,127.0.0.1等)