在 Xamarin 中将 Windows.Networking.Sockets 用于 Windows Phone

Using Windows.Networking.Sockets in Xamarin for Windows Phone

我在我的跨平台应用程序中使用 System.Net.Sockets 作为 TCP/IP Client。我有 SharedProject,其中 class 负责 connecting/receiving 数据。我可以在 Android 中 运行 应用程序,但我发现 System.Net.SocketsWindows Phone 8.1 中不可用。我读到它与 Windows Phone 一起工作,我可以使用 Windows.Networking.Sockets,但是当我在 Shared Project 中的 class 中添加 using Windows.Networking.Sockets 时,我得到错误:

The type or namespace name 'Windows' could not be found

我的问题是如何将 System.Net.SocketsWindows.Networking.SocketsWindows Phone 8.1 一起使用?

根据此 previous question,您需要将 System.Dll 添加到您的项目中才能使用 System.Net.Sockets

或者你也可以试试这个Sockets Plugin for Xamarin

好的,我通过进入共享 Class 库解决了我的问题,接下来我双击 .NET,然后从左侧 select Windows 并单击按钮 'Add to References in Selected Project in Solution Explorer' 靠近搜索栏。