Skip to content

Infragistics Community Forum / Desktop / Ultimate UI for Windows Forms / System.NullReferenceException while setting data source in UltraWinGrid.v8.2

System.NullReferenceException while setting data source in UltraWinGrid.v8.2

New Discussion
MP
MP asked on Mar 7, 2019 10:22 PM

 

Hi,

I am getting the following error while setting the datasouce of the Wingrid. The error is sporadic. The data source is a list of business objects.

The line of code is : grid.DataSource = dataSouce;

 

The error seems to occur when the grid is bound to a list of objects and I try to rebind the grid with a new list of objects (typically I need to do this when there is a new item to be added to the list).

When I inspect this list (of business objects), everything looks okay. None of the objects themselves are null.

I would appreciate any help. Thanks.

 

System.NullReferenceException was unhandled

Message=”Object reference not set to an instance of an object.Source=”Infragistics2.Win.UltraWinGrid.v8.2″

StackTrace:

at Infragistics.Win.UltraWinGrid.UltraGridBase.Set_ListManager(Object newDataSource, String newDataMember)

at Infragistics.Win.UltraWinGrid.UltraGridBase.set_DataSource(Object value)

 

at PortfolioMonitor.UserControls.ObjectGrid.BindGrid(IGridDataBroker obj, UltraGrid grid) in C:\…………..

 

Sign In to post a reply

Replies

  • 0
    Mike Saltzman
    Mike Saltzman answered on Jul 22, 2008 3:40 PM

    The onlything that springs to mind is that perhaps you are using multiple threads in your application and the data is not getting properly marshalled to the UI Thread? Is your app using multiple threads?

    • 0
      QuietSeditionist
      QuietSeditionist answered on Feb 5, 2009 2:38 AM

      I am having the same issue. The first time I set the datasource, it is fine (I am using just a datatable to bind), but sometimes on subsequent times when I set the datasource, I get this stack trace.

      at Infragistics.Win.UltraWinGrid.UltraGridBase.Set_ListManager(Object newDataSource, String newDataMember)
      at Infragistics.Win.UltraWinGrid.UltraGridBase.set_DataSource(Object value) etc….

      I do use background threads in my application, but nowhere in the program flow involved with setting these grids..

      I'm using 2008.3.

      Any ideas?

      • 0
        [Infragistics] Vince McDonald
        [Infragistics] Vince McDonald answered on Feb 5, 2009 4:37 PM

        Are you modifying the data source to which the grid is bound on your background thread?  If so, then the .NET BindingManager is updating your grid on the background thread, which will intermittently cause this type of exception.

      • 0
        QuietSeditionist
        QuietSeditionist answered on Feb 5, 2009 5:02 PM

        I have checked and checked for how this could be happening, but I don't see how it's possible.  I've seen in many forum posts for this and other controls that such kinds of errors are typically traced back to threading issues.  Unless I'm doing something where I don't realize I'm actually using threading (built into some other components I'm using perhaps) then I am stymied.

      • 0
        Mike Saltzman
        Mike Saltzman answered on Feb 6, 2009 2:37 PM

        One of the perils of using threads is that it's sometimes very hard to track down errors that they cause. Does your background thread do anything at all even removely related to the grid or the data source the grid is using? 

        There are essentially two ways a background thread can cause you a problem with the grid. One is if the background thread modifies the data in some way and the data source sends a notification to the grid on the wrong thread.

        The other is if the grid tries to access the data source on the UI thread which it is in the middle of processing something on the background thread. 

        Both of these situations are next to impossible to detect and even more difficult to anticipate. 

      • 0
        QuietSeditionist
        QuietSeditionist answered on Feb 11, 2009 11:26 PM

        Mike,

        I have the troublesome area at least pinpointed if not actually figured out.  I have a reminders service that has a timer ticking every 30 seconds.  This timer elapsing may raise an event which carries a datatable as payload.  This binds to a grid.  The curious thing is, I do not experience any errors in this area, only later and on other, unrelated grids. 

        Are the grids sharing some resource behind the scenes that could be getting involved here?

      • 0
        Mike Saltzman
        Mike Saltzman answered on Feb 13, 2009 3:32 PM

        I'm not sure about the grid's themselves sharing resources.There are certainly shared, static method and resources used by all grids for localized strings and default colors and such.

        But it's not just the grid you have to worry about, it's also the DotNet BindingManager and BindingContexts.  

      • 0
        Aaron Young
        Aaron Young answered on Feb 17, 2009 4:16 PM

         I'm not sure if you have figured this out yet, but I ran into something very similar yesterday and it turned out to be that the Grid had been disposed (It was on a form that had been disposed but hadn't properly released from memory due to other issues.)

        So you may want to check that, perhaps you have the same issue I ran into.

        Regards,

        – Aaron.

      • 0
        Adam
        Adam answered on Sep 8, 2009 5:06 PM

        [quote user="rammam"]

         I'm not sure if you have figured this out yet, but I ran into something very similar yesterday and it turned out to be that the Grid had been disposed (It was on a form that had been disposed but hadn't properly released from memory due to other issues.)

        So you may want to check that, perhaps you have the same issue I ran into.

        Regards,

        – Aaron.

        [/quote]

        I have just found this exact issue in our code – thanks for this solution, works great.

      • 0
        QuietSeditionist
        QuietSeditionist answered on Sep 18, 2009 2:50 AM

        Actually, I did finally figure out my issue.  The timer that I was using was a System.Timers.Timer, not a Windows.Forms.Timer.  The timer that I was using works on a separate thread, not the main thread as a Windows.Forms.Timer does.  When I changed out the variety of timer, I was golden!

      • 0
        Matthias
        Matthias answered on Jan 18, 2012 9:44 AM

        For me solution was

                        ((System.ComponentModel.ISupportInitialize)(grid)).BeginInit();
                        Grid.DataSource = value;
                        ((System.ComponentModel.ISupportInitialize)(grid)).EndInit();

  • 0
    Stephen Speck
    Stephen Speck answered on Mar 7, 2019 10:22 PM

    I realize I'm sort of reopening an old thread, but I had a similar issue and discovered with the help of this StackOverflow thread that I'd somehow blown out the InitializeComponent() call in my constructor. Adding it back fixed the problem.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
MP
Favorites
0
Replies
12
Created On
Mar 07, 2019
Last Post
7 years ago

Suggested Discussions

Tags

Created by

MP

Created on

Mar 7, 2019 10:22 PM

Last activity on

Feb 25, 2026 9:31 AM