nullreferenceexception

Discussion in 'ASP .Net Datagrid Control' started by Jon Oringer, May 18, 2005.

  1. Jon Oringer

    Jon Oringer Guest

    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
    > RealTickTry2.exe!Collector.Form1.Main() Line 327 C#





    --
    Jon Oringer
    http://www.shutterstock.com
    Jon Oringer, May 18, 2005
    #1
    1. Advertising

  2. Jon Oringer

    Guest

    Jon Oringer wrote:
    > 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
    > > RealTickTry2.exe!Collector.Form1.Main() Line 327 C#

    >
    >
    >
    >
    > --
    > Jon Oringer
    > http://www.shutterstock.com



    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.
    , May 18, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fabio Papa
    Replies:
    1
    Views:
    503
    Jim Blizzard [MSFT]
    Sep 24, 2003
  2. William
    Replies:
    0
    Views:
    1,586
    William
    Aug 10, 2004
  3. msnews.microsoft.com

    Help with System.NullReferenceException

    msnews.microsoft.com, Jul 16, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    560
    msnews.microsoft.com
    Jul 16, 2003
  4. Kathy Burke
    Replies:
    0
    Views:
    477
    Kathy Burke
    Jul 24, 2003
  5. Manfred Braun
    Replies:
    3
    Views:
    748
    Manfred Braun
    Aug 30, 2003
Loading...

Share This Page