虽然存在依赖关系和使用,但找不到类型或命名空间名称“Ping”
我正在创建一个程序来ping网络中的计算机。 为此,我试图使用类ping,来自
namespace System.Net.NetworkInformation.Ping
我正在使用ASP.NET 5.0所以我hava project.json文件与我的dependecies
{ "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 Core 5.0文件:Program.cs行:9
问题是Ping不在System.Net.NetworkInfomation
包中(该包甚至存在?)用于CoreCLR( aspnetcore50
)。
根据包搜索网站 ,您需要添加对System.Net.Utilities
包的引用。
- 在Asp.net Core中设置CultureInfo有一个。 作为CurrencyDecimalSeparator而不是,
- 从类库访问Asp.net-core中的appsetting.json
- ASP.NET核心程序在IIS上无需发布即可运行
- 如何在ASP.NET Core中设置强类型配置?
- ASP.Net核心应用程序中LocalAppData的路径
- 如何在ASP.NET Core中将角色添加到Windows身份validation
- 尝试激活’AuthController’时无法解析类型’Microsoft.AspNetCore.Identity.UserManager`的服务
- ASP.NET Core RC2种子数据库
- 在ASP.NET Core Web API中注册新的DelegatingHandler