Question

Hopefully this is a simple fix I have the code:

using System.Net;

namespace WebGet
{
    public partial class Web
    {
        public static void Main()
        {
            WebRequest webRequest;
        }
    }
}

And I get an error saying it cannot find WebRequest (missing assembly reference) I added System.Net as a reference. Do I need to do something else?

Thanks in advance

Was it helpful?

Solution

This works

using System.Net;

namespace WebGet
{
    public partial class Web
    {
        public static void Main()
        {
            WebRequest webRequest;
        }
    }
}

The following shows the references needed.

enter image description here

OTHER TIPS

You should be fine, as all of the references here should be in the core System dll.

You only need to add a reference to the System.dll (which should have happened by default) as the WebRequest class is in there but under the System.Net namespace. Try removing your reference to System.Net but keep the namespace declaration.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top