The name 'WebRequest' doesn't exist

[Netduino 3 wifi]

I’ve managed to get the Blinky sample to work, as well as one or two other samples. But it seems I have something yet uninstalled for my whole setup of VS2015. I tried the Web Request sample and I get this error when I try to build it:

CS0103 The name 'WebRequest' does not exist in the current context

…as well as:

CS0246 The type or namespace name 'HttpWebRequest' could not be found (are you missing a using directive or an assembly reference?)

Since I’m a newbie in the field of Visual Studio and .NET and C#, I have no idea what I’ve missed here. My computer is a brand new Microsoft Surface with almost no other software installed. I’ve copied the source file as it is on the Samples pages. But I notice that the VS2015 editor greys out some of the using lines, telling they are unnecessary. For instance, the “Web Request w/Static IP” sample from Github starts with these lines:

using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
**using System;**
using System.Threading;
using System.Net;
**using System.IO;**
using Microsoft.SPOT;
using Microsoft.SPOT.Net.NetworkInformation;

The lines marked with asterisks are greyed and unnecessary, according to the editor. Just mentioning, if this oddity has to do with the missing ‘WebRequest’ definition/declaration.

It’s getting worse. I thought I had it. I had missed to add some references (Microsoft.SPOT.Hardware, SecretLabs.yadda…) But while following the steps on this page I got lost and either did too much or too little.
Now I’m in a strange situation, where VS2015 doesn’t recognise the Netduino as a device, although Windows does! And I still have the same errors left.

Ok, back on track. Now VS2015 does recognise the board. The simple Blynk works. But I can’t get the web related stuff to work.
CS0103 The name 'WebRequest' does not exist in the current context

CS0246 The type or namespace name 'HttpWebRequest' could not be found (are you missing a using directive or an assembly reference?)

Is System.Net in your usings?

This should also appear in the References section of the project?

Regards,
Mark

Yes, I have it in a using line. Have to check the References yet, I’m not at the right machine right now. But the VS2015 seems to grey out some using lines and tells me that they are not needed. Like the stuff has been included through another using line, don’t know. Meanwhile when I try to search for the names that don’t exist ‘in the current context’, they seem to be defined/declared in the greyed out using libs.
Sorry, if lib and define and declare are the wrong terms here. I have no knowledge of C# and .NET, but I do know C/C++.

Ok, now I got rid of the errors. In the References, it required System.IO for StreamReader to work and System.Http for the web related stuff to work. In my learning process I need yet to learn how to figure out that. The Samples on Wilderness site just have the code for each sample. I couldn’t find the description on what References each sample needs. Or how to immediately tell what Reference each error causing function requires.

1 Like

I’m pleased to hear that you are up and running. I’ve made a note of the problems you experienced and we will try to use this to improve the documentation.

Regards,
Mark

1 Like