我正在使用 VS 2015/Universal 应用程序解决方案开发一个个人项目,我尝试遵循此代码示例:
Asynchronous Server Socket Example
但是当我想创建一个新的 IPHostEntry
或创建一个 Dns.GetHostName()
VS 找不到程序集。
我的解决方案资源管理器上有这些引用资料:
Analyzer
Microsoft.ApplicationInsights
Microsoft.ApplicationInsights.PersistenceChannel
Microsoft.ApplicationInsights.WindowsApps
Microsoft.NETCore.UniversalWindowsPlatform
Universal Windows
以及以下 using 指令:
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;
using System.Net.Sockets;
我还尝试将 System.Net dll 手动添加(位于 C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6 中)到解决方案引用中,但是我收到一条错误消息,告诉我该组件已由生成系统自动添加。
最佳答案
Windows 应用商店应用程序使用不同版本的 .Net 框架,该框架不包含“常规”.Net 框架的许多类,某些缺少的类的功能可能在不同的命名空间和类型下提供。
查看这些页面以了解更多详细信息:
.NET for Windows Store apps overview
System.Net namespaces for UWP apps
在我看来,您尝试使用的接口(interface)和方法不可用。
根据评论进行编辑: 有一个StreamSocket sample for UWP in MSDN
关于c# - 找不到类/添加引用通用窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33613057/