Can't create WebRequest; NullReferenceException thrown

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

All my Web-based .NET 1.1 applications stopped working as soon as I
uninstalled the older versions and installed .Net 2.0 and Visual Studio 2005
this week. The apps use WebClient.DownloadFile() and
WebClient.DownloadData(); in 2.0 those methods always throw WebExceptions
that contain NullReferenceExceptions as their InnerExceptions.

Since WebClient is said to be a thin wrapper around WebRequest/WebResponse,
I wrote a test program to see if I could get around (or help define) the
problem. A similar exception is thrown when I call WebRequest.Create(); the
stack trace ends up in exactly the same place as it did with
WebClient.DownloadFile(). For example:

Uri RequestUri = new Uri("http://www.microsoft.com/");
WebRequest request = WebRequest.Create(RequestUri);

results directly in a NullReferenceException with the following stack trace:

at System.Net.WebRequest.get_PrefixList()
at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
at System.Net.WebRequest.Create(Uri requestUri)

What could be causing this? The URI and local filename are valid, there is
no proxy server involved, Internet access on this machine is working just
fine, and I'm logged on as an Administrator (yeah, I know I shouldn't be, but
....). My configuration wasn't changed except to remove all previous versions
of the framework and Visual Studio before installing version 2.0 of the
framework and Visual Studio 2005.

Many thanks.
 
Back
Top