无法将 System.Net.Utilities 用于 DNX 4.5.1

Unable to use System.Net.Utilities with DNX 4.5.1

首先 post 并完成 C#、DNX,ASP.net 菜鸟所以请保持友善。

我在使用 DNX 4.5.1 构建 ASP.net 5.0 项目时遇到问题。我的 project.json 文件包含以下内容:

  {
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true
  },
  "tooling": {
    "defaultNamespace": "PingTest1"
  },

  "dependencies": {
    "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
    "System.Net.NetworkInformation": "4.1.0-beta-23516",
    "System.Net.Utilities": "4.0.0-beta-23516"
  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel"
  },

  "frameworks": {
    "dnx451": {},
    "dnxcore50": {}
  },

  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "node_modules",
    "bower_components",
    "**.xproj",
    "**.user",
    "**.vspscc"
  ],
  "scripts": {
    "prepublish": [
      "npm install",
      "bower install",
      "gulp clean",
      "gulp min"
    ]
  }
}

并且 "dnu restore" 会按预期安装所有内容。然而,当我 运行 "dnu build" 时,我得到了这两个错误:

error NU1002: The dependency System.Net.Utilities 4.0.0-beta-23516 in project PingTest1 does not support framework DNX,Version=v4.5.1.

DNXCore,Version=v5.0 error CS1061: 'Ping' does not contain a definition for 'Send' and no extension method 'Send' accepting a first argument of type 'Ping' could be found (are you missing a using directive or an assembly reference?)

作为一个完全的菜鸟,我不知道如何纠正这个问题,谷歌搜索也没有找到任何答案。任何帮助将不胜感激。

我的完整源代码可以在这里找到:https://github.com/00101010b/PingTest1

解决方案是从 project.json 文件中删除以下行:

"dnx451": {},

和 运行 以下命令从 Terminal.app 开始依次执行:

dnvm upgrade -r coreclr
dnu restore
dnu build

最后我替换了一些代码以使用 Ping().SendPingAsync()。

这解决了构建问题。但是,我仍然无法对 IP 地址执行 ping 操作...我将很快 post 发布一个关于它的新线程。

非常感谢。