【发布时间】:2016-03-08 02:07:11
【问题描述】:
- 我通过
sudo apt-get install dotnet安装了dotnet - 我使用
dotnet newhello-world 模板创建了一个项目。它构建并运行。 - 架构:amd64 (
dpkg -s) - 版本:1.0.0.001598-1 (
dpkg -s)
然后我想开始使用库 System.Net,所以我更改了模板。我直接从 Microsoft API 文档中添加了 using 指令和代码 sn-p。
我收到错误,特别是在 System.Net 命名空间中找不到类。请注意,编译器不会抱怨我的 using 不好(即无法识别命名空间),它只是找不到该命名空间中的类型。
让我感到惊讶的原因是因为在api docs 中,这些类被指定为 .Net 核心的一部分,所以我认为它们可以“开箱即用”。
dotnet restore; dotnet update 产生:
sr/share/dotnet/bin/dotnet compile-csc @/home/scratch/newapp/obj/Debug/dnxcore50/dotnet-compile.rsp returned Exit Code 1
/home/scratch/newapp/Program.cs(10,13): error CS0246: The type or namespace name 'HttpWebRequest' could not be found (are you missing a using directive or an assembly reference?)
ome/scratch/newapp/Program.cs(11,33): error CS0103: The name 'WebRequest' does not exist in the current context
ome/newapp/Program.cs(11,18): error CS0246: The type or namespace name 'HttpWebRequest' could not be found (are you missing a using directive or an assembly reference?)
(原文如此:截断的 shell 输出为原样)
这是我的代码。
using System;
using System.Net;
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
HttpWebRequest myReq =
(HttpWebRequest)WebRequest.Create("http://www.contoso.com/");
Console.WriteLine("Hello World!");
}
}
}
我错过了什么? System.Net 不是在 .Net Core 附带的标准库中吗?我浏览了 CoreFX,但我觉得它只是 .Net Core 的一个组件,我应该拥有它。如果没有,我该如何安装?
【问题讨论】:
标签: .net ubuntu ubuntu-14.04 .net-core system.net