Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
680
Exception thrown when adding DockableControlPane to DockAreaPane
posted

Hello,

I am using an Infragistics docking manager in my application. In this application I have support for saving layouts and loading them again during runtime. The problem I am having is when I'm disposing an old layout. Below follows a code snippet of what happens when the user has disposed an old layout and selected to create a new one. LayoutWorkspace is a class that inherits from DockableControlPane.

            LayoutWorkspace layoutWorkspace = GenerateWorkspace();

            layoutWorkspace.RootWorkItem = RootWorkItem;

            layoutWorkspace.WorkspacePanel.Click += new EventHandler(OnLayoutWorkspace_Click);

            layoutWorkspace.SetName(workspaceName);

            layoutWorkspace.FlyoutSize = m_MainDockingArea.ActualSize;

            layoutWorkspace.WorkspacePanel.BackColor = Color.White;

            if (!m_DockingManager.DockAreas.Contains(m_MainDockingArea))

            {

                m_MainDockingArea = new DockAreaPane(DockedLocation.DockedLeft);

                m_DockingManager.DockAreas.Add(m_MainDockingArea);

            }

            m_MainDockingArea.Panes.Add(layoutWorkspace);

When this code executes, the if block runs which means that m_MainDockingArea is newly created. My problem is that the last row: "m_MainDockingArea.Panes.Add(layoutWorkspace);" throws an exception saying that I'm trying to use a disposed object. The object mentioned is an old window form that was part of the OLD DockAreaPane. Do you have any idea why this might be happening? I should also mention that it only happens during some special constalation of windows ie. most layouts I have are disposed perfectly fine. I should also mention that we are using v8.2 of infragistic WinForms dlls.

 

Parents
No Data
Reply
  • 27093
    posted

    Hello Johan,

     

    I am not sure I can understand what can cause this exception form the  code snippet exposed in your post. It doesn’t actually show the creation of the LayoutWorkspace, you are probably adding some references to that object.  What else can possibly cause this exception is that something else is referring the m_MainDockingArea and is releasing it “in some special constalation ”. It’s really hard to say what may be the reason for this exception before looking at a working project.

    It might help to post more code describing the behavior of your application or better yet a sample project.

     

     

    Here is some code that might prevent this without altering your logic:

     

    if (!m_DockingManager.DockAreas.Contains(m_MainDockingArea))

    {

         m_DockingManager.DockAreas.Add(new DockAreaPane(DockedLocation.DockedLeft));

         m_MainDockingArea = m_DockingManager.DockAreas[m_DockingManager.DockAreas.Count - 1];

    }

     

    m_DockingManager.DockAreas[m_DockingManager.DockAreas.Count-1].Panes.Add(layoutWorkspace);

     

     

     

     

    Sincerely,

    Petar Monov

    Developer Support Engineer,

    Infragistics, Inc

     

Children