0

数百回に1回、ライフサイトでエラーが発生します。私はチェックし、テストし、テストしてきましたが、何が悪いのか見当がつかないのです。誰か明るいアイデアはありますか?

コードは次のとおりです。

Dim MySqlCommand = New MySqlCommand(SQLC, MySqlConnect)
Try
   Tries = 5
   lg &= " Co("
   Do
       Try : MySqlCommand.Connection.Open()
       Catch ex As Exception
          lg &= " " & ex.Message 
          Wait(0.5) 
       End Try
       If (MySqlCommand.Connection.State <> ConnectionState.Open) Then Tries -= 1 
   Loop While Tries > 0 And MySqlCommand.Connection.State <> ConnectionState.Open
   lg &= ")"
Catch ex As Exception
   lg &= ex.message
End Try

lg &= " " & LCase(Left(SQLC, 5)) & "(Mc"

Try
    lg &= "En" : Dim ret = MySqlCommand.ExecuteNonQuery()
    lg = ""
Catch ex As Exception
   lg &= ":" & ex.message  
End Try

if lg<>"" then  Response.write(lg)

出力は次のとおりです。

Co()updat(McEn:オブジェクト参照がオブジェクトのインスタンスに設定されていません。

4

1 に答える 1

0

log4netなどの .net ロギング フレームワークを使用します。ページで何が起こっているかを記録します。

私の経験では、ロギングは断続的なバグをキャッチする最良の方法です。

于 2012-07-11T08:45:45.637 に答える