我有一個簡單的函數,它試圖從Obout網格過濾器列中獲取值,如果該值爲空,則忽略它並繼續前進。出於某種原因,這段代碼忽略了我的catch塊,並且當輸入字符串爲空時總是顯示一個System.FormatException!嘗試捕捉塊不捕捉?
更奇怪的是,如果我使用visual studio的調試器並在該行上設置一個斷點,catch塊將正常運行(在我繼續該行之後)。我已經確認我的Debug |例外| CLR在拋出時不會被捕獲。我也在生產版本中證實了這一點。
'Get the month selected
Dim MonthSelected As Integer
Try
MonthSelected = CInt(DateCreatedColumn.FilterCriteria.Value)
Catch ex As Exception
'If value is empty/not a number reset the filter
DateCreatedColumn.FilterCriteria.FilterExpression = String.Empty
Return
End Try
如果您在調試器中遇到斷點後繼續運行,會發生什麼? –
嘗試刪除臨時文件,asp.net臨時文件,obj文件夾,重建並重試。即使重新啓動IDE。它看起來像默認加載的調試符號不同步。 – Mrchief
爲什麼你在'Catch'塊中有'Return'? – Jodrell