普段は自分でバグを処理していますが、今回は専門家の助けが必要です!これは私には決して起こりませんでした、そして、データが少なければ少ないほど(通常)何が起こったのかを言うことができなくなります。
簡単なクエリアナライザーを作成しようとしています。私はこれらの種類のクラッシュをランダムに受け取ります:
1)私は次の機能から始めています:
Dim thd As New Thread(AddressOf StartSub)
thd.Start()
次に、Startsubは次のようになります。
Public Sub StartSub()
CheckForIllegalCrossThreadCalls = False
txtExecution.Text = "Executing query..."
Dim query As String = QueryBuilder()
UpdateView(query)
End Sub
次に、updateviewは私が持っているデータグリッドを更新します:
Dim da As New SqlCeDataAdapter(query, connStr)
Dim dt As New DataTable()
Try
da.Fill(dt)
txtExecution.Text = "Query executed successfully."
dgTickets.DataSource = dt
Catch ex As Exception
txtExecution.Text = "Query failed."
tbGrid.BeginInvoke(Sub() tbGrid.SelectedTab = tbGrid.TabPages(1))
End Try
2)次の行のUpdateQueryでコードがクラッシュします(デバッガーはここでクラッシュするとは言いません。すべての行を選択して1つずつ実行することで推測しました):
dgTickets.DataSource = dt
3)デバッガーの内容:NullReferenceExceptionが処理されませんでした(...)新しいキーワードを使用してオブジェクトインスタンスを作成します
スタックトレース:
at System.Windows.Forms.DataGridViewCell.GetEditedFormattedValue(Object value, Int32 rowIndex, DataGridViewCellStyle& dataGridViewCellStyle, DataGridViewDataErrorContexts context)
at System.Windows.Forms.DataGridViewCell.PaintWork(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates cellState, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
at System.Windows.Forms.DataGridViewRow.PaintCells(Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, Int32 rowIndex, DataGridViewElementStates rowState, Boolean isFirstDisplayedRow, Boolean isLastVisibleRow, DataGridViewPaintParts paintParts)
at System.Windows.Forms.DataGridViewRow.Paint(Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, Int32 rowIndex, DataGridViewElementStates rowState, Boolean isFirstDisplayedRow, Boolean isLastVisibleRow)
at System.Windows.Forms.DataGridView.PaintRows(Graphics g, Rectangle boundingRect, Rectangle clipRect, Boolean singleHorizontalBorderAdded)
at System.Windows.Forms.DataGridView.PaintGrid(Graphics g, Rectangle gridBounds, Rectangle clipRect, Boolean singleVerticalBorderAdded, Boolean singleHorizontalBorderAdded)
at System.Windows.Forms.DataGridView.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.DataGridView.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at SQLquery.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
これは実際にはかなりあいまいです。上記のファイルは存在しません。クラッシュする場所は、Try-EndTryでラップされています。さらに、はい、私は絵画イベントを設定しましたが、それは関係するべきではありません(または多分そうですか?)。
これに関するヒントをいただければ幸いです。ビジュアルベーシックエクスプレスエディションを使用していることを付け加えておきます。エラーが発生することがあります。運が良ければ何も起こらず、運が悪ければこのクラッシュが発生することがあります。
ピート。