nullreferenceexception

J

Jon Oringer

I'm having a hard time debugging a nullreferenceexception in my datagrid --
the exception occurs in 'System' .. so its hard to debug..

i can't seem to figure out where the update in my code is causing this
nullreferenceexception ... when i break, the call stack looks like this:

A first chance exception of type 'System.NullReferenceException' occurred in
system.data.dll
Additional information: Object reference not set to an instance of an object.

the only thing i can tell by the call stack - is that the break happens at a
different row each time! so i can't even narrow it down by row updated.

How can i debug this??

here is the call stack:


system.data.dll!System.Data.DataColumnPropertyDescriptor.GetValue(System.Object component = <undefined value>) + 0x29 bytes

system.windows.forms.dll!System.Windows.Forms.DataGridColumnStyle.GetColumnValueAtRow(System.Windows.Forms.CurrencyManager
source = {System.Windows.Forms.RelatedCurrencyManager}, int rowNum = 28) +
0x83 bytes

system.windows.forms.dll!System.Windows.Forms.DataGridTextBoxColumn.Paint(System.Drawing.Graphics
g = {System.Drawing.Graphics}, System.Drawing.Rectangle bounds = {X=37 Y=544
Width=74 Height=17}, System.Windows.Forms.CurrencyManager source =
{System.Windows.Forms.RelatedCurrencyManager}, int rowNum = 28,
System.Drawing.Brush backBrush = {Color={RGB=0x0}}, System.Drawing.Brush
foreBrush = {Color={RGB=0x0}}, bool alignToRight = false) + 0x25 bytes

system.windows.forms.dll!System.Windows.Forms.DataGridRelationshipRow.PaintCellContents(System.Drawing.Graphics
g = {System.Drawing.Graphics}, System.Drawing.Rectangle cellBounds = {X=37
Y=544 Width=74 Height=17}, System.Windows.Forms.DataGridColumnStyle column =
{HeaderText="DISP_NAME"}, System.Drawing.Brush backBr = {Color={RGB=0x0}},
System.Drawing.Brush foreBrush = {Color={RGB=0x0}}, bool alignToRight =
false) + 0x2bd bytes

system.windows.forms.dll!System.Windows.Forms.DataGridRow.PaintData(System.Drawing.Graphics
g = {System.Drawing.Graphics}, System.Drawing.Rectangle bounds = {X=37 Y=544
Width=753 Height=17}, int firstVisibleColumn = 0, int columnCount = 9, bool
alignToRight = false) + 0x276 bytes

system.windows.forms.dll!System.Windows.Forms.DataGridRelationshipRow.Paint(System.Drawing.Graphics
g = {System.Drawing.Graphics}, System.Drawing.Rectangle bounds = {X=37 Y=544
Width=753 Height=18}, System.Drawing.Rectangle trueRowBounds = {X=37 Y=544
Width=753 Height=18}, int firstVisibleColumn = 0, int numVisibleColumns = 9,
bool alignToRight = false) + 0x95 bytes

system.windows.forms.dll!System.Windows.Forms.DataGrid.PaintRows(System.Drawing.Graphics
g = {System.Drawing.Graphics}, System.Drawing.Rectangle boundingRect = {X=2
Y=40 Width=788 Height=550}) + 0x38f bytes

system.windows.forms.dll!System.Windows.Forms.DataGrid.PaintGrid(System.Drawing.Graphics
g = {System.Drawing.Graphics}, System.Drawing.Rectangle gridBounds = {X=2
Y=21 Width=788 Height=569}) + 0x1e2 bytes

system.windows.forms.dll!System.Windows.Forms.DataGrid.OnPaint(System.Windows.Forms.PaintEventArgs
pe = {ClipRectangle={X=2 Y=94 Width=788 Height=18}}) + 0x24d bytes

system.windows.forms.dll!System.Windows.Forms.Control.PaintWithErrorHandling(System.Windows.Forms.PaintEventArgs
e = {ClipRectangle={X=2 Y=94 Width=788 Height=18}}, short layer = 2, bool
disposeEventArgs = false) + 0x85 bytes

system.windows.forms.dll!System.Windows.Forms.Control.WmPaint(System.Windows.Forms.Message m = {System.Windows.Forms.Message}) + 0x570 bytes

system.windows.forms.dll!System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message m = {System.Windows.Forms.Message}) + 0x2d6 bytes

system.windows.forms.dll!ControlNativeWindow.OnMessage(System.Windows.Forms.Message m = {System.Windows.Forms.Message}) + 0x13 bytes

system.windows.forms.dll!ControlNativeWindow.WndProc(System.Windows.Forms.Message m = {System.Windows.Forms.Message}) + 0xda bytes

system.windows.forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(int
hWnd = 134070, int msg = 15, int wparam = 0, int lparam = 0) + 0x3d bytes

system.windows.forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(int dwComponentID = 1, int reason = -1, int pvLoopData = 0) + 0x349 bytes
system.windows.forms.dll!ThreadContext.RunMessageLoopInner(int reason =
-1, System.Windows.Forms.ApplicationContext context =
{System.Windows.Forms.ApplicationContext}) + 0x1f3 bytes
system.windows.forms.dll!ThreadContext.RunMessageLoop(int reason = -1,
System.Windows.Forms.ApplicationContext context =
{System.Windows.Forms.ApplicationContext}) + 0x50 bytes

system.windows.forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm = {Collector.Form1}) + 0x34 bytes
 
S

surfsecret

Jon said:
I'm having a hard time debugging a nullreferenceexception in my datagrid --
the exception occurs in 'System' .. so its hard to debug..

i can't seem to figure out where the update in my code is causing this
nullreferenceexception ... when i break, the call stack looks like this:

A first chance exception of type 'System.NullReferenceException' occurred in
system.data.dll
Additional information: Object reference not set to an instance of an object.

the only thing i can tell by the call stack - is that the break happens at a
different row each time! so i can't even narrow it down by row updated.

How can i debug this??

here is the call stack:
system.data.dll!System.Data.DataColumnPropertyDescriptor.GetValue(System.Object
component = said:
system.windows.forms.dll!System.Windows.Forms.DataGridColumnStyle.GetColumnValueAtRow(System.Windows.Forms.CurrencyManager

source = {System.Windows.Forms.RelatedCurrencyManager}, int rowNum = 28) +
0x83 bytes

system.windows.forms.dll!System.Windows.Forms.DataGridTextBoxColumn.Paint(System.Drawing.Graphics

g = {System.Drawing.Graphics}, System.Drawing.Rectangle bounds = {X=37 Y=544
Width=74 Height=17}, System.Windows.Forms.CurrencyManager source =
{System.Windows.Forms.RelatedCurrencyManager}, int rowNum = 28,
System.Drawing.Brush backBrush = {Color={RGB=0x0}}, System.Drawing.Brush
foreBrush = {Color={RGB=0x0}}, bool alignToRight = false) + 0x25 bytes
system.windows.forms.dll!System.Windows.Forms.DataGridRelationshipRow.PaintCellContents(System.Drawing.Graphics

g = {System.Drawing.Graphics}, System.Drawing.Rectangle cellBounds = {X=37
Y=544 Width=74 Height=17}, System.Windows.Forms.DataGridColumnStyle column =
{HeaderText="DISP_NAME"}, System.Drawing.Brush backBr = {Color={RGB=0x0}},
System.Drawing.Brush foreBrush = {Color={RGB=0x0}}, bool alignToRight =
false) + 0x2bd bytes

system.windows.forms.dll!System.Windows.Forms.DataGridRow.PaintData(System.Drawing.Graphics

g = {System.Drawing.Graphics}, System.Drawing.Rectangle bounds = {X=37 Y=544
Width=753 Height=17}, int firstVisibleColumn = 0, int columnCount = 9, bool
alignToRight = false) + 0x276 bytes

system.windows.forms.dll!System.Windows.Forms.DataGridRelationshipRow.Paint(System.Drawing.Graphics

g = {System.Drawing.Graphics}, System.Drawing.Rectangle bounds = {X=37 Y=544
Width=753 Height=18}, System.Drawing.Rectangle trueRowBounds = {X=37 Y=544
Width=753 Height=18}, int firstVisibleColumn = 0, int numVisibleColumns = 9,
bool alignToRight = false) + 0x95 bytes

system.windows.forms.dll!System.Windows.Forms.DataGrid.PaintRows(System.Drawing.Graphics

g = {System.Drawing.Graphics}, System.Drawing.Rectangle boundingRect = {X=2
Y=40 Width=788 Height=550}) + 0x38f bytes

system.windows.forms.dll!System.Windows.Forms.DataGrid.PaintGrid(System.Drawing.Graphics

g = {System.Drawing.Graphics}, System.Drawing.Rectangle gridBounds = {X=2
Y=21 Width=788 Height=569}) + 0x1e2 bytes

system.windows.forms.dll!System.Windows.Forms.DataGrid.OnPaint(System.Windows.Forms.PaintEventArgs

pe = {ClipRectangle={X=2 Y=94 Width=788 Height=18}}) + 0x24d bytes

system.windows.forms.dll!System.Windows.Forms.Control.PaintWithErrorHandling(System.Windows.Forms.PaintEventArgs

e = {ClipRectangle={X=2 Y=94 Width=788 Height=18}}, short layer = 2, bool
disposeEventArgs = false) + 0x85 bytes
system.windows.forms.dll!System.Windows.Forms.Control.WmPaint(System.Windows.Forms.Message
m = {System.Windows.Forms.Message}) + 0x570 bytessystem.windows.forms.dll!System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message
m = {System.Windows.Forms.Message}) + 0x2d6 bytessystem.windows.forms.dll!ControlNativeWindow.OnMessage(System.Windows.Forms.Message
m = {System.Windows.Forms.Message}) + 0x13 bytessystem.windows.forms.dll!ControlNativeWindow.WndProc(System.Windows.Forms.Message
m = {System.Windows.Forms.Message}) + 0xda bytes
system.windows.forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(int

hWnd = 134070, int msg = 15, int wparam = 0, int lparam = 0) + 0x3d bytes
system.windows.forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(int
dwComponentID = 1, int reason = -1, int pvLoopData = 0) + 0x349 bytes
system.windows.forms.dll!ThreadContext.RunMessageLoopInner(int reason =
-1, System.Windows.Forms.ApplicationContext context =
{System.Windows.Forms.ApplicationContext}) + 0x1f3 bytes
system.windows.forms.dll!ThreadContext.RunMessageLoop(int reason = -1,
System.Windows.Forms.ApplicationContext context =
{System.Windows.Forms.ApplicationContext}) + 0x50 bytes
system.windows.forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form
mainForm = {Collector.Form1}) + 0x34 bytes

I think i figured it out - looks like i was calling a datagrid update
method from another thread - without knowing i was on another thread. I
had to use form.Invoke - works now.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top