C# 类型或命名空间名称';Ping&x27;找不到,尽管存在dependencie和using
我正在创建一个在网络中ping计算机的小程序。 为此,我尝试使用ping类,从C# 类型或命名空间名称';Ping&x27;找不到,尽管存在dependencie和using,c#,asp.net-core,console-application,ping,C#,Asp.net Core,Console Application,Ping,我正在创建一个在网络中ping计算机的小程序。 为此,我尝试使用ping类,从 namespace System.Net.NetworkInformation.Ping 我使用的是ASP.NET 5.0,所以我有一个project.json文件和依赖项 { "version": "1.0.0-*", "dependencies": { "NetworkSniffer": "1.0.0-*", "Microsoft.AspNet.Mvc": "
namespace System.Net.NetworkInformation.Ping
我使用的是ASP.NET 5.0,所以我有一个project.json文件和依赖项
{
"version": "1.0.0-*",
"dependencies": {
"NetworkSniffer": "1.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0.0-beta2"
},
"commands": {
"run": "run"
},
"frameworks": {
"aspnet50": {
"dependencies": {
"System.Console": "4.0.0-beta-22231",
"System.Net.NetworkInformation": "4.0.10-beta-22231"
}
},
"aspnetcore50": {
"dependencies": {
"System.Console": "4.0.0-beta-22231",
"System.Net.NetworkInformation": "4.0.10-beta-22231"
}
}
}
}
仍然给出错误的控制台代码的简化版本为:
using System.Net.NetworkInformation;
namespace TestApp
{
public class Program
{
public static void Main(string[] args)
{
Ping p = new Ping();
}
}
}
尝试编译此代码时的完整错误是:
代码:错误CS0246说明:类型或命名空间名称“Ping”可能不正确
找不到(是否缺少using指令或程序集
参考?)项目:TestApp.ASP.NET核心5.0文件:Program.cs行:9
问题是Ping不在CoreCLR(
aspnetcore50
)的System.Net.networkinformation
包中(该包是否存在?)
根据,您需要添加对
System.Net.Utilities
包的引用。问题在于,Ping不在CoreCLR(aspnetcore50
)的System.Net.networkinformation
包中(该包是否存在?)
根据,您需要添加对System.Net.Utilities
包的引用