继续获得第一次机会异常错误

时间:2013-07-03 22:11:38

标签: vb.net exception-handling

当我运行我的程序时,代码正确捕获超时异常,但后来我收到一条弹出消息:

  

Microsoft.VisualBasic.dll中出现'System.NullReferenceException'类型的第一次机会异常

也说这个:

  

对象变量或未设置块变量。

这是我的代码:

Dim rt As String = ""
Dim out As String
Dim wRequest As WebRequest
Dim wResponse As WebResponse
Dim SR As StreamReader
Dim time As Date

time = Now()

Try
    wRequest = WebRequest.Create(Address)
    wRequest.Timeout = 10000
    wResponse = wRequest.GetResponse
    SR = New StreamReader(wResponse.GetResponseStream)
    rt = SR.ReadToEnd
    SR.Close()
Catch wex As System.Net.WebException
    If wex.Status = WebExceptionStatus.Timeout Then
        MessageBox.Show("Could not establish a connection to the selected exchange server.", "Connection Timed Out", MessageBoxButtons.OK, MessageBoxIcon.Warning)
    End If
End Try

0 个答案:

没有答案