gpt4 book ai didi

c# - 无法将 System.Net.Utilities 与 DNX 4.5.1 一起使用

转载 作者:太空宇宙 更新时间:2023-11-03 12:55:41 24 4
gpt4 key购买 nike

第一次发帖并完成 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 操作……我会很快发布一个新的主题。

非常感谢。

关于c# - 无法将 System.Net.Utilities 与 DNX 4.5.1 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34012942/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com