![]() |
Click here to advertise with us
|
|
|||||||
| VB.NET General Discussion VB.NET general discussion area |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
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
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. |
|
||||
|
The documentation indicates that if the Status IS ProtocolError then Response will contain a WebResponse. You're trying to get Response when Status is NOT ProtocolError, in which case it's obviously not guaranteed to not be Nothing.
__________________
![]() 2007, 2008, 2009, 2010 Why is my data not saved to my database? | Communicating between multiple forms MSDN: Data Walkthroughs | "How Do I?" Videos My Blog: Custom Events | Dynamic GDI+ Drawing |
|
||||
|
Um, obviously in your case it's Nothing. Have you checked what the actual status is? Maybe that will give you a clue what the issue is. After all, for some errors it should be obvious that there'd be no response because the server couldn't have responded.
__________________
![]() 2007, 2008, 2009, 2010 Why is my data not saved to my database? | Communicating between multiple forms MSDN: Data Walkthroughs | "How Do I?" Videos My Blog: Custom Events | Dynamic GDI+ Drawing |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|