Ticket T664982
Visible to All Users

NullReferenceException is thrown in LayoutControl when calling XtraUserControl.Dispose

created 7 years ago

Exception is thrown when calling Dispose method on XtraUserControl

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at DevExpress.XtraLayout.LayoutDesignerMethodsProvider.DevExpress.XtraLayout.ILayoutDesignerMethods.BeginChangeUpdate()
   at DevExpress.XtraLayout.LayoutControlImplementor.ProcessLookAndFeelStyleChanged()
   at DevExpress.XtraLayout.LayoutControlImplementor.OnLookAndFeelStyleChanged(Object sender, EventArgs e)
   at DevExpress.XtraLayout.LayoutControl.OnHandleCreated(EventArgs e)
   at System.Windows.Forms.Control.WmCreate(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at DevExpress.XtraLayout.LayoutControl.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)

Comments (2)
Nadezhda (DevExpress Support) 7 years ago

    Hello,

    My attempts to reproduce this behavior were unsuccessful. I have attached a sample project. Please modify this project so that it illustrates the issue and send it to us.
    I look forward to your response.

      Hi,

      I managed to isolate the issue from our code. Project is attached.
      After starting, click on the question mark (second tab will open), then close the program.
      Exception is thrown in DesignerControl.Designer.cs at line 22.

      This is a result of our explicit dispose implementation, but still it seems like a bug at your side.

      Thanks for looking into it.

      Regards,
      Koen

      Answers approved by DevExpress Support

      created 7 years ago

      Hi,

      I have reviewed your project and reproduced the issue. It occurs since you override the XtraUserControl1.Dispose method and dispose of layoutControlGroup1, layoutControlItem1designerControl1, and xtraScrollableControl1 manually. There is no necessity to do this since all child controls will be disposed of by using the standard mechanism automatically. In turn, LayoutControl will properly dispose of all its items and groups.

      Once you remove this code, everything will operate as expected. Let me know if you need further assistance.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.