C# C# Streams and Data Processing Streaming Data on the Net WebClient

Kevin Jordan
Kevin Jordan
3,953 Points

WebClient Method cannot be found in Visual Studio 2017 Community Edition

For the var webClient code section. The WebClient method cannot be found. I have both using System.Net; and System.Net.WebClient, but neither solve the problem. I have also tried HttpClient with no luck either.

This is the error I get:

Severity Code Description Project File Line Suppression State Error CS0234 The type or namespace name 'WebClient' does not exist in the namespace 'System.Net' (are you missing an assembly reference?)

Screenshot of code: https://gyazo.com/5a455a81da546e581b3bfef6a520ce54

2 Answers

Tom Kapon
Tom Kapon
5,359 Points

Hi did you add a reference to the nugget package Microsoft.Net.Http? for the HttpClient if not you should add it in project.json "dependencies": { }

for the System.Net you need to add the reference by going to solution explorer right click on the project than on add than on add references find System.Net and add it. And there is no System.Net.WebClient only System.Net.

Tom Kapon
Tom Kapon
5,359 Points

And just for your information webclient isnt a method its a class of the system.net namespace in the System.dll Assembly.

Adam McGrade
Adam McGrade
26,174 Points

I had the same problem. It turned out that I was working with a .NET Core console application rather than a .NET Standard console application. I think .NET Core is missing some of these classes. Once I recreated my project as a Standard app, I was able to get access to the classes in the System.Net namespace.