Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

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.

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,333 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.