C1RibbonForm raise exception 'Cannot access a disposed object.'

Posted by: fvicente on 25 November 2018, 12:07 pm EST

    • Post Options:
    • Link

    Posted 25 November 2018, 12:07 pm EST

    Hello

    I have a MDI with a toolbar with 8 buttons. When I open 5 winforms or more and then start to close the 5 windows open, the system raise an exception when I close the second or third.

    Each Form inherits of C1RibbonForm, for example:

    public partial class frmVentana1 : C1RibbonForm

    If I dont use C1RibbonForm and inherits of Form, the application doesn’t raise error and run perfect, for example:

    public partial class frmVentana1 : Form

    Is clear that the error is with the C1RibbonForm!

    I am using the last version for today: Version=4.0.20183.338

    I think there are a problem with your Control!

    The exception is:

    System.ObjectDisposedException: ‘Cannot access a disposed object.’

    Details:

    at System.Drawing.Icon.get_Handle()

    at System.Drawing.Icon.get_Size()

    at System.Drawing.Icon.BmpFrame()

    at System.Drawing.Icon.ToBitmap()

    at System.Windows.Forms.MdiControlStrip.GetTargetWindowIcon()

    at System.Windows.Forms.MdiControlStrip…ctor(IWin32Window target)

    at System.Windows.Forms.Form.UpdateMdiControlStrip(Boolean maximized)

    at System.Windows.Forms.Form.UpdateToolStrip()

    at System.Windows.Forms.Form.OnMdiChildActivate(EventArgs e)

    at C1.Win.C1Ribbon.C1RibbonForm.OnMdiChildActivate(EventArgs e)

    at System.Windows.Forms.Form.ActivateMdiChildInternal(Form form)

    at System.Windows.Forms.Form.WmMdiActivate(Message& m)

    at System.Windows.Forms.Form.WndProc(Message& m)

    at C1.Win.C1Ribbon.C1RibbonForm.aa(Message& A_0)

    at C1.Win.C1Ribbon.C1RibbonForm.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)

    at System.Windows.Forms.UnsafeNativeMethods.DefMDIChildProc(IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)

    at System.Windows.Forms.Form.DefWndProc(Message& m)

    at System.Windows.Forms.Control.WndProc(Message& m)

    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)

    at System.Windows.Forms.Form.WndProc(Message& m)

    at C1.Win.C1Ribbon.C1RibbonForm.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)

  • Posted 27 November 2018, 7:21 am EST

    Hello!

    I’ve created a sample application as per the said specifications, but could not replicate the behaviour using the latest builds.

    Test_MDIForms.zip

    If you are able to replicate the issue in this sample also, kindly share your system environment details along with a demonstrating video.

    Regards,

    Meenakshi

  • Posted 3 December 2018, 12:16 am EST

    Hello

    The error is when the children forms are maximized, and you use a C1Ribbon. I added an example. You need open the 5 forms then start to close. The error will be raised!

    Please I need a solution for the error in the Control!

    Thank you.

  • Posted 3 December 2018, 5:35 am EST

    Hi,

    same problem here since a few weeks. Also in a MDI-Application at maximized window-state…

    Error occurs randomly. To the present day I didn’t get it reproduced on my development-machine.

    I googled a little bit and found two interesting links:

    https://social.msdn.microsoft.com/Forums/windows/en-US/2de9797a-d71c-4846-92ad-5371a541b439/cannot-access-a-disposed-objectobject-name-icon?forum=winformsapplications

    https://stackoverflow.com/questions/28699172/exception-cannot-access-a-disposed-object-is-coming-from-non-user-code

    I changed my source code to the mentioned “me.hide” in Form.Closing and it gets better after releasing the new version to our users. It’s not a 100 percent solution, because I get the error reported furthermore. But this is much less than before.

    Maybe it’s a workaround for you too?

    But you’re right, in earlier versions of the ribbon-control this problem doesn’t exist…

    Greetings

    Lars

    PS: In our company mentioned error only occurs on Windows 10 machines.

  • Posted 3 December 2018, 6:01 am EST

    Hi

    @Lars

    Thank you for sharing this information on this post.

    @Francisco

    > “I added an example.”

    It seems, you tried to attach the sample application to your post. However, it could not be successfully attached. Can you please try reattach it as zipped file?

    Also, let me know if the error occurs randomly at your end or you are able to replicate it each time on running the application.

    Regards,

    Meenakshi

  • Posted 3 December 2018, 9:04 am EST

    Hello

    Again:

    Test_MDIForms.zip

  • Posted 6 December 2018, 2:12 am EST

    Hello Francisco!

    Thanks for the sample. However, I could run it without any issue with the latest 4.0.20183.338 builds. And. I’m attaching the demonstrating video for your reference.

    Vid_MDIForms.zip

    In order to investigate it further, as requested earlier, please share the following information:

    1. System environment details at your end.
    2. Is the issue reproducible each time when you run the sample, or does it occur randomly?
    • Meenakshi
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels