2015-12-01 32 views
2

第一篇文章,並完成C#,DNX,ASP.net noob所以請好。無法使用System.Net.Utilities與DNX 4.5.1

我在使用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建」,我得到這兩個錯誤:

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

+1

如果有人最近發現這個問題,System.Net.Utilities包被重命名爲System.Net.Ping。 – TZHX

回答

1

解決的辦法是刪除project.json文件以下行:

"dnx451": {}, 

而且爲了從Terminal.app運行以下命令:

dnvm upgrade -r coreclr 
dnu restore 
dnu build 

最後,我用我的一些代碼替換爲使用Ping()。SendPingAsync()。

這解決了構建問題。不過,我仍然遇到ping IP地址的問題......我將很快發佈一個關於它的新主題。

非常感謝。