- I installed dotnet via
sudo apt-get install dotnet
- I created a project using
dotnet new
hello-world template. It builds and runs. - Architecture: amd64 (
dpkg -s
) - Version: 1.0.0.001598-1 (
dpkg -s
)
Then I wanted to start using the library System.Net so I altered the template. I added a using
directive and a code snippet directly from the Microsoft API docs.
I get errors, specifically that the classes are not found in the System.Net namespace. Note the compiler doesn't complain that my using
is bad (i.e. doesn't recognize the namespace), it just can't find the types in that namespace.
The reason that surprises me is because in the api docs these classes are specified as part of .Net core, so I assumed they would be available "out-of-the-box".
dotnet restore; dotnet update
yields:
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?)
(sic: the truncated shell output is AS-IS)
Here is my code.
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!");
}
}
}
What am I missing? Isn't System.Net in the standard libs that come with .Net Core? I browsed CoreFX, but I got the feeling it is just a component of .Net Core and I should have it. If not, how do I install that?