View Single Post
  #1 (permalink)  
Old 12-02-2008, 1:51 AM
Spilled Spilled is offline
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Nov 2008
Location: USA
Age: 22
Posts: 14
Reputation: 18
Spilled is on a distinguished programming path ahead
Default WebException Throws NullReferenceException

Hello all when I try to Handle my WebException I'm getting a NullReferenceException when I try to Display the Error. Here is my code:

Code:
            Try
                res = req.GetResponse()
                RaiseEvent UpdateResponse(threadID, res.StatusCode.ToString & " - " & res.StatusDescription)
                res.Close()
            Catch Err As WebException
                If Err.Status = WebExceptionStatus.ProtocolError Then
                    RaiseEvent UpdateResponse(threadID, "401 - Unauthorised")
                Else
                    RaiseEvent UpdateResponse(threadID, CType(Err.Response, HttpWebResponse).StatusCode.ToString & " - " & CType(Err.Response, HttpWebResponse).StatusDescription)
                    RetryComboNeedNewProxy = True
                End If
            End Try
RaiseEvent UpdateResponse(threadID, CType(Err.Response, HttpWebResponse).StatusCode.ToString & " - " & CType(Err.Response, HttpWebResponse).StatusDescription)
Is where i get the NullReferenceException, Err.response is "nothing" in the debugger, WebException.Response suppose to return the WebResponse type of the exception? Thanks in advance.
Reply With Quote