We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

NullReferenceException from BarManager

Has anybody ever met this exception? Any ideas of how to solve it? Thanks in advance. The detail message is as below: System.NullReferenceException: A BarItem (Text: ) that is not part of a BarManager is found in the menus or toolbars. Make sure to add the BarItem to a BarManager before adding it to the menus or toolbars. at Syncfusion.Windows.Forms.Tools.XPMenus.MainFrameBarManager.RefreshContainer(IBarItemContainer container) at Syncfusion.Windows.Forms.Tools.XPMenus.MainFrameBarManager.UpdateBarsInManager(BarManager manager) at Syncfusion.Windows.Forms.Tools.XPMenus.MainFrameBarManager.UpdateBars() at Syncfusion.Windows.Forms.Tools.XPMenus.MainFrameBarManager.OnFormActivated(Form form) at Syncfusion.Windows.Forms.Tools.XPMenus.MainFrameBarManager.FormActivated(Object sender, EventArgs e) at System.Windows.Forms.Form.OnActivated(EventArgs e) at System.Windows.Forms.Form.set_Active(Boolean value) at System.Windows.Forms.Form.WmActivate(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

9 Replies

MJ Mano J Syncfusion Team November 17, 2005 03:06 PM UTC

Hi Andy, After looking into the exception, I have found that one of the barItem in your coding with no text is not added to MainFrameBarManager.Items collection. Please make sure that all the parentBarItems or BarItems that are created has to be added to MainFrameBarManager before adding into menus. this.MainFrameBarManager1.Items.AddRange(new Syncfusion.Windows.Forms.Tools.XPMenus.BarItem[] { this.barItem1, this.barItem2, this.parentBarItem1, this.parentBarItem2, this.barItem3}); Please let me know if you have any questions. Regards, Mano


AW Andy Wu November 18, 2005 09:03 AM UTC

The problem doesm''t occur often. Mostly, our project is okey. Even if this happens, it disappears after several trys to run our project. Any ideas on why this happens?


MJ Mano J Syncfusion Team November 18, 2005 04:32 PM UTC

Hi Andy, Are you creating menus through code or through designer? Also let me know the version of Essential studio you are working and .Net Framework version. Regards, Mano


AD Administrator Syncfusion Team November 18, 2005 06:21 PM UTC

Mano, Please check my post in the General forum. Regards, thomas


LK Leow Kah Man August 2, 2006 03:37 AM UTC

I have an MDI parent with MainFrameBarManager.
I have a child form (call it Form1) with ChildFrameBarManager.
I have a child form (call it Form2) with ChildFrameBarManager.

1. When I''m in a Form1, I right click on it, a popup menu appears.

2. This popup menu has a BarItem with a shortcut key of Control+M.
The same BarItem also appears in the MDI parent (due to merging of menus between the parent MDI and child MDI forms)

3. When I click on this BarItem using mouse, Form2 appears, no problems. This is correct.

4. Now repeat step 1, then press Control+M

5. I get the same exception as described above.

Before you jump to a quick conclusion on this problem, note that I could open Form2 if I use mouse but not if I use Control+M


MJ Mano J Syncfusion Team August 2, 2006 06:51 PM UTC

Hi Leow,

I could not reproduce this exception in my test sample. Could you please test this sample in your side and let me know if you are able to reproduce the problem, else please

Also, please let me know the Essential Studio version you are using?

Thanks,
Mano

MenuSample1.zip


LK Leow Kah Man August 3, 2006 01:40 AM UTC

Hi,

Thanks for preparing the initial sample.

For the time being, I do not have much time to add-on to your sample to demonstrate the problem.
I would have to insert some toolbars, icons, virtual GridControl, TabBarSplitterControl, etc.
This is because the popup menu appears on right clicking on the virtual GridControl cells.

When I do or when I managed to identify the culprit of the problem, I shall let you know without delay.

The workaround that I am using at the moment is to Disable the form that is showing the popup menu prior to loading another MDI child form.


LK Leow Kah Man August 4, 2006 10:27 AM UTC

Version 4.202.0.37


MJ Mano J Syncfusion Team August 4, 2006 08:31 PM UTC

Hi Leow,

We are currently working on this issue as we are still unable to reproduce it in our subsystems. I will update you soon with more details.

Thanks for your patience.

Regards,
Mano

Loader.
Live Chat Icon For mobile
Up arrow icon