WebRequest Exception: "The attempted operation is not supported for the type of object referenced"

  • Thread starter Thread starter Taylor Brown
  • Start date Start date
T

Taylor Brown

We have written an asynchronous download class that uses the WebRequest
to perform downloads. Things are working fine in-house, and it's fine
for the vast majority of our users, but there is an increasingly large
of people who are getting the following exception:

Exception Type: System.Net.Sockets.SocketException
ErrorCode: 10045
SocketErrorCode: OperationNotSupported
NativeErrorCode: 10045
Message: The attempted operation is not supported for the type of
object referenced

Doing a search on that phrase ("The attempted operation is not
supported for the type of object referenced") almost immediately led me
to this page: "How to determine and recover from Winsock2 corruption"
http://support.microsoft.com/kb/811259

Using the instructions on that page has worked for 100% of the users
with the problem! At first I though, "Great!" But now we're seeing a
lot of these, and I'm starting to think that since it's not that
isolated, it might not really be a true "problem" on their machines.
It might be a firewall program or some other incomptaibility. Have
other people seen this before? Do you know of something "innocuous"
that could be causing the SocketException?

Any hints, guesses, or shots in the dark would be greatly appreciated.

Many thanks,

Taylor
 
In case someone else comes across this error and stumbles across this
thread, I have found and fixed it in our app.

I have posted the results of my research and well as the details of my
final workaround here:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=678862&SiteID=1
(Watch for link wraparound)

In case that link dissapears some day, just know this: Be wary of
calling the asynchronous versions of the methods to download files if
you are creating asynchronous threads in your app with the
Delegate.BeginInvoke method. (This includes:
WebClient.DownloadFileAsync and WebRequest.BeginGetResponse)
It will work on most machines, but it won't work on machines that have
"corrupted" winsock settings. I use the term "corrupted" loosely. The
machines that fit this definition were often just machines with foreign
LSPs, and that didn't have any other networking problems.

Cheers,

Taylor
 
Back
Top