我在 OS X 上使用 visual studio code 并尝试使用 System.Net.Http 和 dnxcore50 发出 HTTP 请求。当我运行 mcs -debug Program.cs
时,我收到消息:
Program.cs(2,18): error CS0234: The type or namespace name 'Http' does not exist in the namespace 'System.Net'. Are you missing 'System.Net.Http' assembly reference?`
这是我的 project.json:
{
"version": "1.0.0-*",
"description": "Console Application",
"authors": [
"your name"
],
"tags": [
""
],
"projectUrl": "",
"licenseUrl": "",
"dependencies": {
"Newtonsoft.Json": "7.0.1",
"System.Net.Http": "4.0.1-beta-23217",
"Microsoft.AspNet.WebApi.Client": "5.2.3"
},
"commands": {
"ConsoleApplication": "ConsoleApplication"
},
"frameworks": {
"dnx451": {},
"dnxcore50": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23217",
"System.Collections": "4.0.11-beta-23217",
"System.Console": "4.0.0-beta-23217",
"System.Linq": "4.0.1-beta-23217",
"System.Threading": "4.0.11-beta-23217"
}
}
}
最佳答案
如果您使用 DNX,则不会直接调用 C# 编译器。 Mcs 不知道如何编译新项目。你应该使用 dnu build
相反:
dnu build <path to your project.json>
关于c# - ASP.NET 5 控制台应用程序 dnxcore50 缺少 `System.Net.Http' 程序集引用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33155145/