Home All Groups Group Topic Archive Search About

Problem (dispose?) MDI forms

Author
16 Mar 2007 11:08 AM
SealedClassSingleton
Hi,

I've a very weird error in an MDI application. From time to time, when
closing a child form, the form is closed correctly (put some writelines on
different places: form_closing / form_closed / dispose) but is not removed
from the MDIparent.

When I iterate over all child forms I can close the form a second time (?)
even all controls are already disposed.

When clicking on the "closed" form in the MDI list, I get an ObjectDisposed
Exception.

A first chance exception of type 'System.ObjectDisposedException' occurred
in System.Windows.Forms.dll
System.ObjectDisposedException: Cannot access a disposed object.

Anyone who had similar problems ? Suggestions ?

Author
16 Mar 2007 1:41 PM
VJ
Sure.. Close does not mean the object is immediately available to be garbage
collected and disposed. There is still other objects created by child Form2
in memory, as long as all of it are not cleared Form2 will exist. Now these
are not limited to Child form controls, they can be threads or any other
objects created when Form2 i.e. child was in memory and working...

HTH
VJ
Show quote
"SealedClassSingleton" <Eagle@community.nospam> wrote in message
news:3238DC52-45DD-4B33-93F0-DA6A19AAAEA0@microsoft.com...
> Hi,
>
> I've a very weird error in an MDI application. From time to time, when
> closing a child form, the form is closed correctly (put some writelines on
> different places: form_closing / form_closed / dispose) but is not removed
> from the MDIparent.
>
> When I iterate over all child forms I can close the form a second time (?)
> even all controls are already disposed.
>
> When clicking on the "closed" form in the MDI list, I get an
> ObjectDisposed
> Exception.
>
> A first chance exception of type 'System.ObjectDisposedException' occurred
> in System.Windows.Forms.dll
> System.ObjectDisposedException: Cannot access a disposed object.
>
> Anyone who had similar problems ? Suggestions ?
Author
16 Mar 2007 1:56 PM
SealedClassSingleton
I agree that closing a form doens't mean that the form is immediate released,
but the problem is a little more subtile: I'm sure that the form is disposed
(I put some code in the destructor), but it remains accessible through the
mdilist and in the midichildren property.  As far as I know, no addtional
child are created inside the form (I additionaly even check if all controls
are removed...)

I agree, that it could take a while to be GCed (depending on memory
consumption / load and other things) but once a form is closed it shouldn't
be accessible anymore (In my situation is even worde bacause I'm using a
tabbed mdi interface and the users stills sees the "closed" window in the MDI
tab. Clicking on it generates the exception)...

Show quote
"VJ" wrote:

> Sure.. Close does not mean the object is immediately available to be garbage
> collected and disposed. There is still other objects created by child Form2
> in memory, as long as all of it are not cleared Form2 will exist. Now these
> are not limited to Child form controls, they can be threads or any other
> objects created when Form2 i.e. child was in memory and working...
>
> HTH
> VJ
> "SealedClassSingleton" <Eagle@community.nospam> wrote in message
> news:3238DC52-45DD-4B33-93F0-DA6A19AAAEA0@microsoft.com...
> > Hi,
> >
> > I've a very weird error in an MDI application. From time to time, when
> > closing a child form, the form is closed correctly (put some writelines on
> > different places: form_closing / form_closed / dispose) but is not removed
> > from the MDIparent.
> >
> > When I iterate over all child forms I can close the form a second time (?)
> > even all controls are already disposed.
> >
> > When clicking on the "closed" form in the MDI list, I get an
> > ObjectDisposed
> > Exception.
> >
> > A first chance exception of type 'System.ObjectDisposedException' occurred
> > in System.Windows.Forms.dll
> > System.ObjectDisposedException: Cannot access a disposed object.
> >
> > Anyone who had similar problems ? Suggestions ?
>
>
>
Author
16 Mar 2007 2:05 PM
VJ
Very tricky. I truly agree. Have developed MDI apps for last few years as
programmer.  I don't like solutions like these, but sometimes after close
you can just set the object to null.

One thing tho'.. if you tabbed MDI, how is a child Form in a tab?, and you
do frm.Close().. and I am assuming you remove the Tab. Just curious on those
steps..!

VJ

Show quote
"SealedClassSingleton" <Eagle@community.nospam> wrote in message
news:FDADA37E-82F9-44D8-B3BB-9A28CCF86761@microsoft.com...
>I agree that closing a form doens't mean that the form is immediate
>released,
> but the problem is a little more subtile: I'm sure that the form is
> disposed
> (I put some code in the destructor), but it remains accessible through the
> mdilist and in the midichildren property.  As far as I know, no addtional
> child are created inside the form (I additionaly even check if all
> controls
> are removed...)
>
> I agree, that it could take a while to be GCed (depending on memory
> consumption / load and other things) but once a form is closed it
> shouldn't
> be accessible anymore (In my situation is even worde bacause I'm using a
> tabbed mdi interface and the users stills sees the "closed" window in the
> MDI
> tab. Clicking on it generates the exception)...
>
> "VJ" wrote:
>
>> Sure.. Close does not mean the object is immediately available to be
>> garbage
>> collected and disposed. There is still other objects created by child
>> Form2
>> in memory, as long as all of it are not cleared Form2 will exist. Now
>> these
>> are not limited to Child form controls, they can be threads or any other
>> objects created when Form2 i.e. child was in memory and working...
>>
>> HTH
>> VJ
>> "SealedClassSingleton" <Eagle@community.nospam> wrote in message
>> news:3238DC52-45DD-4B33-93F0-DA6A19AAAEA0@microsoft.com...
>> > Hi,
>> >
>> > I've a very weird error in an MDI application. From time to time, when
>> > closing a child form, the form is closed correctly (put some writelines
>> > on
>> > different places: form_closing / form_closed / dispose) but is not
>> > removed
>> > from the MDIparent.
>> >
>> > When I iterate over all child forms I can close the form a second time
>> > (?)
>> > even all controls are already disposed.
>> >
>> > When clicking on the "closed" form in the MDI list, I get an
>> > ObjectDisposed
>> > Exception.
>> >
>> > A first chance exception of type 'System.ObjectDisposedException'
>> > occurred
>> > in System.Windows.Forms.dll
>> > System.ObjectDisposedException: Cannot access a disposed object.
>> >
>> > Anyone who had similar problems ? Suggestions ?
>>
>>
>>
Author
16 Mar 2007 2:20 PM
SealedClassSingleton
I don't call the close myselft. It's done by the tabbedMDI interface from
Janus (www.janusys.com). It looks like a tab where eveyry form is represented
on a seperate tabpage.

I don't think it's related to them, because I use these controls in a number
of projects and it don't have similar problems. It looks like in this case
the notification to the mdiparent gets lost...


Show quote
"VJ" wrote:

> Very tricky. I truly agree. Have developed MDI apps for last few years as
> programmer.  I don't like solutions like these, but sometimes after close
> you can just set the object to null.
>
> One thing tho'.. if you tabbed MDI, how is a child Form in a tab?, and you
> do frm.Close().. and I am assuming you remove the Tab. Just curious on those
> steps..!
>
> VJ
>
> "SealedClassSingleton" <Eagle@community.nospam> wrote in message
> news:FDADA37E-82F9-44D8-B3BB-9A28CCF86761@microsoft.com...
> >I agree that closing a form doens't mean that the form is immediate
> >released,
> > but the problem is a little more subtile: I'm sure that the form is
> > disposed
> > (I put some code in the destructor), but it remains accessible through the
> > mdilist and in the midichildren property.  As far as I know, no addtional
> > child are created inside the form (I additionaly even check if all
> > controls
> > are removed...)
> >
> > I agree, that it could take a while to be GCed (depending on memory
> > consumption / load and other things) but once a form is closed it
> > shouldn't
> > be accessible anymore (In my situation is even worde bacause I'm using a
> > tabbed mdi interface and the users stills sees the "closed" window in the
> > MDI
> > tab. Clicking on it generates the exception)...
> >
> > "VJ" wrote:
> >
> >> Sure.. Close does not mean the object is immediately available to be
> >> garbage
> >> collected and disposed. There is still other objects created by child
> >> Form2
> >> in memory, as long as all of it are not cleared Form2 will exist. Now
> >> these
> >> are not limited to Child form controls, they can be threads or any other
> >> objects created when Form2 i.e. child was in memory and working...
> >>
> >> HTH
> >> VJ
> >> "SealedClassSingleton" <Eagle@community.nospam> wrote in message
> >> news:3238DC52-45DD-4B33-93F0-DA6A19AAAEA0@microsoft.com...
> >> > Hi,
> >> >
> >> > I've a very weird error in an MDI application. From time to time, when
> >> > closing a child form, the form is closed correctly (put some writelines
> >> > on
> >> > different places: form_closing / form_closed / dispose) but is not
> >> > removed
> >> > from the MDIparent.
> >> >
> >> > When I iterate over all child forms I can close the form a second time
> >> > (?)
> >> > even all controls are already disposed.
> >> >
> >> > When clicking on the "closed" form in the MDI list, I get an
> >> > ObjectDisposed
> >> > Exception.
> >> >
> >> > A first chance exception of type 'System.ObjectDisposedException'
> >> > occurred
> >> > in System.Windows.Forms.dll
> >> > System.ObjectDisposedException: Cannot access a disposed object.
> >> >
> >> > Anyone who had similar problems ? Suggestions ?
> >>
> >>
> >>
>
>
>
Author
16 Mar 2007 2:36 PM
VJ
aah 3rd party control. You could post on their site or ask them see if there
are known issues that you should look for. You could use the debug
environment to see if all objects are cleaned up as promised.!

VJ

Show quote
"SealedClassSingleton" <SealedClassSingle***@discussions.microsoft.com>
wrote in message news:D4FAA0B5-8D96-4AAC-9B80-144C06D06D8D@microsoft.com...
>I don't call the close myselft. It's done by the tabbedMDI interface from
> Janus (www.janusys.com). It looks like a tab where eveyry form is
> represented
> on a seperate tabpage.
>
> I don't think it's related to them, because I use these controls in a
> number
> of projects and it don't have similar problems. It looks like in this case
> the notification to the mdiparent gets lost...
>
>
> "VJ" wrote:
>
>> Very tricky. I truly agree. Have developed MDI apps for last few years as
>> programmer.  I don't like solutions like these, but sometimes after close
>> you can just set the object to null.
>>
>> One thing tho'.. if you tabbed MDI, how is a child Form in a tab?, and
>> you
>> do frm.Close().. and I am assuming you remove the Tab. Just curious on
>> those
>> steps..!
>>
>> VJ
>>
>> "SealedClassSingleton" <Eagle@community.nospam> wrote in message
>> news:FDADA37E-82F9-44D8-B3BB-9A28CCF86761@microsoft.com...
>> >I agree that closing a form doens't mean that the form is immediate
>> >released,
>> > but the problem is a little more subtile: I'm sure that the form is
>> > disposed
>> > (I put some code in the destructor), but it remains accessible through
>> > the
>> > mdilist and in the midichildren property.  As far as I know, no
>> > addtional
>> > child are created inside the form (I additionaly even check if all
>> > controls
>> > are removed...)
>> >
>> > I agree, that it could take a while to be GCed (depending on memory
>> > consumption / load and other things) but once a form is closed it
>> > shouldn't
>> > be accessible anymore (In my situation is even worde bacause I'm using
>> > a
>> > tabbed mdi interface and the users stills sees the "closed" window in
>> > the
>> > MDI
>> > tab. Clicking on it generates the exception)...
>> >
>> > "VJ" wrote:
>> >
>> >> Sure.. Close does not mean the object is immediately available to be
>> >> garbage
>> >> collected and disposed. There is still other objects created by child
>> >> Form2
>> >> in memory, as long as all of it are not cleared Form2 will exist. Now
>> >> these
>> >> are not limited to Child form controls, they can be threads or any
>> >> other
>> >> objects created when Form2 i.e. child was in memory and working...
>> >>
>> >> HTH
>> >> VJ
>> >> "SealedClassSingleton" <Eagle@community.nospam> wrote in message
>> >> news:3238DC52-45DD-4B33-93F0-DA6A19AAAEA0@microsoft.com...
>> >> > Hi,
>> >> >
>> >> > I've a very weird error in an MDI application. From time to time,
>> >> > when
>> >> > closing a child form, the form is closed correctly (put some
>> >> > writelines
>> >> > on
>> >> > different places: form_closing / form_closed / dispose) but is not
>> >> > removed
>> >> > from the MDIparent.
>> >> >
>> >> > When I iterate over all child forms I can close the form a second
>> >> > time
>> >> > (?)
>> >> > even all controls are already disposed.
>> >> >
>> >> > When clicking on the "closed" form in the MDI list, I get an
>> >> > ObjectDisposed
>> >> > Exception.
>> >> >
>> >> > A first chance exception of type 'System.ObjectDisposedException'
>> >> > occurred
>> >> > in System.Windows.Forms.dll
>> >> > System.ObjectDisposedException: Cannot access a disposed object.
>> >> >
>> >> > Anyone who had similar problems ? Suggestions ?
>> >>
>> >>
>> >>
>>
>>
>>
Author
16 Mar 2007 2:53 PM
SealedClassSingleton
I already did this action before posting to the MSDN forurm. There are no
known issues...

Show quote
"VJ" wrote:

> aah 3rd party control. You could post on their site or ask them see if there
> are known issues that you should look for. You could use the debug
> environment to see if all objects are cleaned up as promised.!
>
> VJ
>
> "SealedClassSingleton" <SealedClassSingle***@discussions.microsoft.com>
> wrote in message news:D4FAA0B5-8D96-4AAC-9B80-144C06D06D8D@microsoft.com...
> >I don't call the close myselft. It's done by the tabbedMDI interface from
> > Janus (www.janusys.com). It looks like a tab where eveyry form is
> > represented
> > on a seperate tabpage.
> >
> > I don't think it's related to them, because I use these controls in a
> > number
> > of projects and it don't have similar problems. It looks like in this case
> > the notification to the mdiparent gets lost...
> >
> >
> > "VJ" wrote:
> >
> >> Very tricky. I truly agree. Have developed MDI apps for last few years as
> >> programmer.  I don't like solutions like these, but sometimes after close
> >> you can just set the object to null.
> >>
> >> One thing tho'.. if you tabbed MDI, how is a child Form in a tab?, and
> >> you
> >> do frm.Close().. and I am assuming you remove the Tab. Just curious on
> >> those
> >> steps..!
> >>
> >> VJ
> >>
> >> "SealedClassSingleton" <Eagle@community.nospam> wrote in message
> >> news:FDADA37E-82F9-44D8-B3BB-9A28CCF86761@microsoft.com...
> >> >I agree that closing a form doens't mean that the form is immediate
> >> >released,
> >> > but the problem is a little more subtile: I'm sure that the form is
> >> > disposed
> >> > (I put some code in the destructor), but it remains accessible through
> >> > the
> >> > mdilist and in the midichildren property.  As far as I know, no
> >> > addtional
> >> > child are created inside the form (I additionaly even check if all
> >> > controls
> >> > are removed...)
> >> >
> >> > I agree, that it could take a while to be GCed (depending on memory
> >> > consumption / load and other things) but once a form is closed it
> >> > shouldn't
> >> > be accessible anymore (In my situation is even worde bacause I'm using
> >> > a
> >> > tabbed mdi interface and the users stills sees the "closed" window in
> >> > the
> >> > MDI
> >> > tab. Clicking on it generates the exception)...
> >> >
> >> > "VJ" wrote:
> >> >
> >> >> Sure.. Close does not mean the object is immediately available to be
> >> >> garbage
> >> >> collected and disposed. There is still other objects created by child
> >> >> Form2
> >> >> in memory, as long as all of it are not cleared Form2 will exist. Now
> >> >> these
> >> >> are not limited to Child form controls, they can be threads or any
> >> >> other
> >> >> objects created when Form2 i.e. child was in memory and working...
> >> >>
> >> >> HTH
> >> >> VJ
> >> >> "SealedClassSingleton" <Eagle@community.nospam> wrote in message
> >> >> news:3238DC52-45DD-4B33-93F0-DA6A19AAAEA0@microsoft.com...
> >> >> > Hi,
> >> >> >
> >> >> > I've a very weird error in an MDI application. From time to time,
> >> >> > when
> >> >> > closing a child form, the form is closed correctly (put some
> >> >> > writelines
> >> >> > on
> >> >> > different places: form_closing / form_closed / dispose) but is not
> >> >> > removed
> >> >> > from the MDIparent.
> >> >> >
> >> >> > When I iterate over all child forms I can close the form a second
> >> >> > time
> >> >> > (?)
> >> >> > even all controls are already disposed.
> >> >> >
> >> >> > When clicking on the "closed" form in the MDI list, I get an
> >> >> > ObjectDisposed
> >> >> > Exception.
> >> >> >
> >> >> > A first chance exception of type 'System.ObjectDisposedException'
> >> >> > occurred
> >> >> > in System.Windows.Forms.dll
> >> >> > System.ObjectDisposedException: Cannot access a disposed object.
> >> >> >
> >> >> > Anyone who had similar problems ? Suggestions ?
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
Author
16 Mar 2007 3:03 PM
VJ
So you have narrowed it to a project and all machines where the project
runs?

VJ

Show quote
"SealedClassSingleton" <Eagle@community.nospam> wrote in message
news:3238DC52-45DD-4B33-93F0-DA6A19AAAEA0@microsoft.com...
> Hi,
>
> I've a very weird error in an MDI application. From time to time, when
> closing a child form, the form is closed correctly (put some writelines on
> different places: form_closing / form_closed / dispose) but is not removed
> from the MDIparent.
>
> When I iterate over all child forms I can close the form a second time (?)
> even all controls are already disposed.
>
> When clicking on the "closed" form in the MDI list, I get an
> ObjectDisposed
> Exception.
>
> A first chance exception of type 'System.ObjectDisposedException' occurred
> in System.Windows.Forms.dll
> System.ObjectDisposedException: Cannot access a disposed object.
>
> Anyone who had similar problems ? Suggestions ?
Author
17 Mar 2007 7:08 AM
SealedClassSingleton
Yes, it's only on this project but on all client machines...

Show quote
"VJ" wrote:

> So you have narrowed it to a project and all machines where the project
> runs?
>
> VJ
>
> "SealedClassSingleton" <Eagle@community.nospam> wrote in message
> news:3238DC52-45DD-4B33-93F0-DA6A19AAAEA0@microsoft.com...
> > Hi,
> >
> > I've a very weird error in an MDI application. From time to time, when
> > closing a child form, the form is closed correctly (put some writelines on
> > different places: form_closing / form_closed / dispose) but is not removed
> > from the MDIparent.
> >
> > When I iterate over all child forms I can close the form a second time (?)
> > even all controls are already disposed.
> >
> > When clicking on the "closed" form in the MDI list, I get an
> > ObjectDisposed
> > Exception.
> >
> > A first chance exception of type 'System.ObjectDisposedException' occurred
> > in System.Windows.Forms.dll
> > System.ObjectDisposedException: Cannot access a disposed object.
> >
> > Anyone who had similar problems ? Suggestions ?
>
>
>
Author
17 Mar 2007 2:57 PM
VJ
I still some how believe some object related to the child is not cleaned up.
But again this may be not the case. You can have null checks and do a
specific null assignment to get around. Not a best solution, but avoids
exception.

Does the exception stack trace help?

VJ
Show quote
"SealedClassSingleton" <SealedClassSingle***@discussions.microsoft.com>
wrote in message news:83A0A7C8-D2C6-46B1-9960-CDBFBCBE1C5E@microsoft.com...
> Yes, it's only on this project but on all client machines...
>
> "VJ" wrote:
>
>> So you have narrowed it to a project and all machines where the project
>> runs?
>>
>> VJ
>>
>> "SealedClassSingleton" <Eagle@community.nospam> wrote in message
>> news:3238DC52-45DD-4B33-93F0-DA6A19AAAEA0@microsoft.com...
>> > Hi,
>> >
>> > I've a very weird error in an MDI application. From time to time, when
>> > closing a child form, the form is closed correctly (put some writelines
>> > on
>> > different places: form_closing / form_closed / dispose) but is not
>> > removed
>> > from the MDIparent.
>> >
>> > When I iterate over all child forms I can close the form a second time
>> > (?)
>> > even all controls are already disposed.
>> >
>> > When clicking on the "closed" form in the MDI list, I get an
>> > ObjectDisposed
>> > Exception.
>> >
>> > A first chance exception of type 'System.ObjectDisposedException'
>> > occurred
>> > in System.Windows.Forms.dll
>> > System.ObjectDisposedException: Cannot access a disposed object.
>> >
>> > Anyone who had similar problems ? Suggestions ?
>>
>>
>>
Author
18 Mar 2007 3:56 PM
SealedClassSingleton
Not really, It give some ecxception on the activation on one of the first
controls on
the form

A first chance exception of type 'System.ObjectDisposedException' occurred
in System.Windows.Forms.dll
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'MaskEdit'.
   at System.Windows.Forms.Control.CreateHandle()
   at System.Windows.Forms.TextBoxBase.CreateHandle()
   at System.Windows.Forms.Control.get_Handle()
   at System.Windows.Forms.Control.GetSafeHandle(IWin32Window window)
   at System.Windows.Forms.ToolTip.Hide(IWin32Window win)
   at System.Windows.Forms.ToolTip.HideAllToolTips()
   at System.Windows.Forms.ToolTip.BaseFormDeactivate(Object sender,
EventArgs e)
   at System.Windows.Forms.Form.OnDeactivate(EventArgs e)
   at System.Windows.Forms.Form.set_Active(Boolean value)
   at System.Windows.Forms.Form.DeactivateMdiChild()
   at System.Windows.Forms.Form.WmMdiActivate(Message& m)
   at System.Windows.Forms.Form.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.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.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.CallWindowProc(IntPtr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
   at System.Windows.Forms.Control.DefWndProc(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.MdiClient.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 Janus.Windows.UI.JNSZ.a(IntPtr , IntPtr , Int32 , IntPtr , IntPtr )
   at Janus.Windows.UI.Internal.JNSAQ.WndProc(IntPtr hWnd, Int32 iMsg,
IntPtr wParam, IntPtr lParam)
   at Janus.Windows.UI.Dock.Internal.JNSDA.WndProc(IntPtr hWnd, Int32 msg,
IntPtr wParam, IntPtr lParam)
   at Janus.Windows.UI.Internal.JNSAQ.a(IntPtr , Int32 , IntPtr , IntPtr )
   at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd,
Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam,
Int32 lparam)
   at System.Windows.Forms.Form.Activate()
   at Janus.Windows.UI.Dock.UIMdiTabGroup.c(JNSBG )
   at Janus.Windows.UI.Dock.UIMdiTabGroup.OnMouseDown(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons
button, Int32 clicks)
   at System.Windows.Forms.Control.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.DispatchMessageW(MSG& msg)
   at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
   at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at CCREK.Midas.GUI.Classes.Launcher.Main(String[] args) in


Show quote
"VJ" wrote:

> I still some how believe some object related to the child is not cleaned up.
> But again this may be not the case. You can have null checks and do a
> specific null assignment to get around. Not a best solution, but avoids
> exception.
>
> Does the exception stack trace help?
>
> VJ
> "SealedClassSingleton" <SealedClassSingle***@discussions.microsoft.com>
> wrote in message news:83A0A7C8-D2C6-46B1-9960-CDBFBCBE1C5E@microsoft.com...
> > Yes, it's only on this project but on all client machines...
> >
> > "VJ" wrote:
> >
> >> So you have narrowed it to a project and all machines where the project
> >> runs?
> >>
> >> VJ
> >>
> >> "SealedClassSingleton" <Eagle@community.nospam> wrote in message
> >> news:3238DC52-45DD-4B33-93F0-DA6A19AAAEA0@microsoft.com...
> >> > Hi,
> >> >
> >> > I've a very weird error in an MDI application. From time to time, when
> >> > closing a child form, the form is closed correctly (put some writelines
> >> > on
> >> > different places: form_closing / form_closed / dispose) but is not
> >> > removed
> >> > from the MDIparent.
> >> >
> >> > When I iterate over all child forms I can close the form a second time
> >> > (?)
> >> > even all controls are already disposed.
> >> >
> >> > When clicking on the "closed" form in the MDI list, I get an
> >> > ObjectDisposed
> >> > Exception.
> >> >
> >> > A first chance exception of type 'System.ObjectDisposedException'
> >> > occurred
> >> > in System.Windows.Forms.dll
> >> > System.ObjectDisposedException: Cannot access a disposed object.
> >> >
> >> > Anyone who had similar problems ? Suggestions ?
> >>
> >>
> >>
>
>
>
Author
18 Mar 2007 4:27 PM
VJ
Hello,

Using third party controls is always tricky, You don't have source code that
I can run to replicate the problem. I understand that is going to be tricky
in this situation as you use third party tools and controls. The key for you
should be to make sure that not get caught up on the broken piece. Examine
other code around, that might lead to it. Objects left un disposed can cause
a Pain. There is a tool called FxCop ( Microsoft tool) that helps identify
some issue with design and code flow. You could also get a trial version of
memory profiler and see if that spots the issue. Its time to stretch out the
normal means and try to solve the problem.

I am trying to give pointers here to you, as I don't have your full code or
sample that can re-produce the problem. Please do spend time eliminating
options, upto now we have done a lot of elimination and that is not enough
for your problem. Also if you can ask somebody from your team to look at it,
always a second pair of eyes helps.

Hope you solve the problem, let me know if we here can help you in any other
way.
VJ

Show quote
"SealedClassSingleton" <SealedClassSingle***@discussions.microsoft.com>
wrote in message news:6A3CC82F-F252-45E3-AE86-1E6DFB32EBCE@microsoft.com...
> Not really, It give some ecxception on the activation on one of the first
> controls on
> the form
>
> A first chance exception of type 'System.ObjectDisposedException' occurred
> in System.Windows.Forms.dll
> System.ObjectDisposedException: Cannot access a disposed object.
> Object name: 'MaskEdit'.
>   at System.Windows.Forms.Control.CreateHandle()
>   at System.Windows.Forms.TextBoxBase.CreateHandle()
>   at System.Windows.Forms.Control.get_Handle()
>   at System.Windows.Forms.Control.GetSafeHandle(IWin32Window window)
>   at System.Windows.Forms.ToolTip.Hide(IWin32Window win)
>   at System.Windows.Forms.ToolTip.HideAllToolTips()
>   at System.Windows.Forms.ToolTip.BaseFormDeactivate(Object sender,
> EventArgs e)
>   at System.Windows.Forms.Form.OnDeactivate(EventArgs e)
>   at System.Windows.Forms.Form.set_Active(Boolean value)
>   at System.Windows.Forms.Form.DeactivateMdiChild()
>   at System.Windows.Forms.Form.WmMdiActivate(Message& m)
>   at System.Windows.Forms.Form.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.ContainerControl.WndProc(Message& m)
>   at System.Windows.Forms.Form.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.CallWindowProc(IntPtr
> wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
>   at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
>   at System.Windows.Forms.Control.DefWndProc(Message& m)
>   at System.Windows.Forms.Control.WndProc(Message& m)
>   at System.Windows.Forms.MdiClient.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 Janus.Windows.UI.JNSZ.a(IntPtr , IntPtr , Int32 , IntPtr , IntPtr )
>   at Janus.Windows.UI.Internal.JNSAQ.WndProc(IntPtr hWnd, Int32 iMsg,
> IntPtr wParam, IntPtr lParam)
>   at Janus.Windows.UI.Dock.Internal.JNSDA.WndProc(IntPtr hWnd, Int32 msg,
> IntPtr wParam, IntPtr lParam)
>   at Janus.Windows.UI.Internal.JNSAQ.a(IntPtr , Int32 , IntPtr , IntPtr )
>   at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd,
> Int32 msg, IntPtr wParam, IntPtr lParam)
>   at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam,
> Int32 lparam)
>   at System.Windows.Forms.Form.Activate()
>   at Janus.Windows.UI.Dock.UIMdiTabGroup.c(JNSBG )
>   at Janus.Windows.UI.Dock.UIMdiTabGroup.OnMouseDown(MouseEventArgs e)
>   at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons
> button, Int32 clicks)
>   at System.Windows.Forms.Control.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.DispatchMessageW(MSG& msg)
>   at
> System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
> dwComponentID, Int32 reason, Int32 pvLoopData)
>   at
> System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
> reason, ApplicationContext context)
>   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
> reason, ApplicationContext context)
>   at System.Windows.Forms.Application.Run(Form mainForm)
>   at CCREK.Midas.GUI.Classes.Launcher.Main(String[] args) in
>
>
> "VJ" wrote:
>
>> I still some how believe some object related to the child is not cleaned
>> up.
>> But again this may be not the case. You can have null checks and do a
>> specific null assignment to get around. Not a best solution, but avoids
>> exception.
>>
>> Does the exception stack trace help?
>>
>> VJ
>> "SealedClassSingleton" <SealedClassSingle***@discussions.microsoft.com>
>> wrote in message
>> news:83A0A7C8-D2C6-46B1-9960-CDBFBCBE1C5E@microsoft.com...
>> > Yes, it's only on this project but on all client machines...
>> >
>> > "VJ" wrote:
>> >
>> >> So you have narrowed it to a project and all machines where the
>> >> project
>> >> runs?
>> >>
>> >> VJ
>> >>
>> >> "SealedClassSingleton" <Eagle@community.nospam> wrote in message
>> >> news:3238DC52-45DD-4B33-93F0-DA6A19AAAEA0@microsoft.com...
>> >> > Hi,
>> >> >
>> >> > I've a very weird error in an MDI application. From time to time,
>> >> > when
>> >> > closing a child form, the form is closed correctly (put some
>> >> > writelines
>> >> > on
>> >> > different places: form_closing / form_closed / dispose) but is not
>> >> > removed
>> >> > from the MDIparent.
>> >> >
>> >> > When I iterate over all child forms I can close the form a second
>> >> > time
>> >> > (?)
>> >> > even all controls are already disposed.
>> >> >
>> >> > When clicking on the "closed" form in the MDI list, I get an
>> >> > ObjectDisposed
>> >> > Exception.
>> >> >
>> >> > A first chance exception of type 'System.ObjectDisposedException'
>> >> > occurred
>> >> > in System.Windows.Forms.dll
>> >> > System.ObjectDisposedException: Cannot access a disposed object.
>> >> >
>> >> > Anyone who had similar problems ? Suggestions ?
>> >>
>> >>
>> >>
>>
>>
>>
Author
18 Mar 2007 4:34 PM
VJ
I shall give you a typical example we went through with a 3rd party menu /
toolbar tool that we got when we where with .NET 1.1. They offered nice
toolbar menus and merging for a MDI, but it took a while to realize they
where using threads to merge of Toolbars.. turned to be a nightmare than
what we imagined.  I am not saying this is all 3rd party tools and companies
this will happen. Just that we need to be well aware we work with a binaries
and not source files to identify problems easily, just like working .NET
framework. Also these situations most of the problems are erratic and never
consistent. So be patient and go outside norms to solve the problem. I think
you are just focused on just one point, that might not be the case here..

VJ

Show quote
"VJ" <nonewsaddr***@yahoo.com> wrote in message
news:OwXM2w9ZHHA.3520@TK2MSFTNGP04.phx.gbl...
> So you have narrowed it to a project and all machines where the project
> runs?
>
> VJ
>
> "SealedClassSingleton" <Eagle@community.nospam> wrote in message
> news:3238DC52-45DD-4B33-93F0-DA6A19AAAEA0@microsoft.com...
>> Hi,
>>
>> I've a very weird error in an MDI application. From time to time, when
>> closing a child form, the form is closed correctly (put some writelines
>> on
>> different places: form_closing / form_closed / dispose) but is not
>> removed
>> from the MDIparent.
>>
>> When I iterate over all child forms I can close the form a second time
>> (?)
>> even all controls are already disposed.
>>
>> When clicking on the "closed" form in the MDI list, I get an
>> ObjectDisposed
>> Exception.
>>
>> A first chance exception of type 'System.ObjectDisposedException'
>> occurred
>> in System.Windows.Forms.dll
>> System.ObjectDisposedException: Cannot access a disposed object.
>>
>> Anyone who had similar problems ? Suggestions ?
>
>
Author
19 Mar 2007 4:04 AM
Linda Liu [MSFT]
Hi Eagle,

Based on my understanding, you have an MDI application and the MDI parent
has a menu for its MDI children list. The problem is that when you close an
MDI child form, it is still available in the MDI children list within the
menu and in the MdiChildren property of the MDI parent. If you click on the
'closed' form, you get an ObjectDisposedException. If I'm off base, please
feel free to let me know.

I  have performed a test in both VS.NET 2003 and VS 2005, but couldn't
reproduce the problem on either of them.

In my test VS.NET 2003 project, I add a Menu to the MDI parent form, and
add a MenuItem in the Menu. I set the MdiList property of the MenuItem to
True.

When the program is run and I open several MDI child forms, all the MDI
child forms are listed under the MenuItem. When I close one of the MDI
child forms, it disappears from the MDI child list and doesn't exist in the
MdiChildren property of the MDI parent, either.

In my test VS 2005 project, I add a MenuStrip on the MDI parent form and
add a ToolStripMenuItem to the MenuStrip. I set the MdiWindowListItem
property of the MenuStrip to the ToolStripMenuItem. When the program is
run, the program behaves the same as my VS.NET 2003 test program does.

Does this problem always exist when you close the MDI child form?

Since I couldn't reproduce the problem on my side, it's hard for me to
troubleshoot the problem. If possible, could you please send me a sample
project that could just reproduce the problem? To get my actual email
address, remove 'online' from my displayed email address.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Author
19 Mar 2007 7:38 AM
SealedClassSingleton
Hi,

Your description og the problem is right. The problem doesn't always occurs.
I cann't force it to happen and I cann't easily isolate part of the project
and send it over.

regards,

Bart.

Show quote
"Linda Liu [MSFT]" wrote:

> Hi Eagle,
>
> Based on my understanding, you have an MDI application and the MDI parent
> has a menu for its MDI children list. The problem is that when you close an
> MDI child form, it is still available in the MDI children list within the
> menu and in the MdiChildren property of the MDI parent. If you click on the
> 'closed' form, you get an ObjectDisposedException. If I'm off base, please
> feel free to let me know.
>
> I  have performed a test in both VS.NET 2003 and VS 2005, but couldn't
> reproduce the problem on either of them.
>
> In my test VS.NET 2003 project, I add a Menu to the MDI parent form, and
> add a MenuItem in the Menu. I set the MdiList property of the MenuItem to
> True.
>
> When the program is run and I open several MDI child forms, all the MDI
> child forms are listed under the MenuItem. When I close one of the MDI
> child forms, it disappears from the MDI child list and doesn't exist in the
> MdiChildren property of the MDI parent, either.
>
> In my test VS 2005 project, I add a MenuStrip on the MDI parent form and
> add a ToolStripMenuItem to the MenuStrip. I set the MdiWindowListItem
> property of the MenuStrip to the ToolStripMenuItem. When the program is
> run, the program behaves the same as my VS.NET 2003 test program does.
>
> Does this problem always exist when you close the MDI child form?
>
> Since I couldn't reproduce the problem on my side, it's hard for me to
> troubleshoot the problem. If possible, could you please send me a sample
> project that could just reproduce the problem? To get my actual email
> address, remove 'online' from my displayed email address.
>
> Sincerely,
> Linda Liu
> Microsoft Online Community Support
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications.

> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx.
> ==================================================

> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
Author
21 Mar 2007 8:34 AM
Linda Liu [MSFT]
Hi Bart,

Thank you for your reply.

What the VS IDE are you using, VS.NET 2003 or VS 2005?

Could you please tell me what controls are on the MDI child form? From the
call stack you have provided, it seems that MDI child form has ToolTip
component on it. If so, the problem may be caused by the form's being
incorrectly disposed during form closing.

As VJ has suggested, you may dispose all the controls/unmanaged objects, if
any, on the MDI child form explicitly from within the form's override
Dispose(bool) method. You may also set the MDI child form's MdiParent
property to null in the form's Closed event handler.

Please try my suggestion and let me know the result.

If you have anything unclear, please feel free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support
Author
23 Mar 2007 1:26 PM
Linda Liu [MSFT]
Hi Bart,

How about the proble now?

If the problem is still not solved and you need our further assistance,
please feel free to let me know.

Thank you for using our MSDN Managed Newsgroup Support Service!


Sincerely,
Linda Liu
Microsoft Online Community Support
Author
26 Nov 2007 3:22 PM
sathishkumar kalivaradhan
I am also getting exactly same call stack trace, so i think the tooltip causeing problem because while setting the tool tip we used give control, while closing form control get disposed but form call the tooltip.hide method with control which was disposed .

i want to know how do i dispose tool tip control?

Thanks and Regards
K.Sathishkumar

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com
Author
19 Mar 2007 3:01 PM
VJ
Linda,

They are using a custom user control, not just windows Forms MDI.

VJ

Show quote
"Linda Liu [MSFT]" <v-l***@online.microsoft.com> wrote in message
news:Ian4sudaHHA.2368@TK2MSFTNGHUB02.phx.gbl...
> Hi Eagle,
>
> Based on my understanding, you have an MDI application and the MDI parent
> has a menu for its MDI children list. The problem is that when you close
> an
> MDI child form, it is still available in the MDI children list within the
> menu and in the MdiChildren property of the MDI parent. If you click on
> the
> 'closed' form, you get an ObjectDisposedException. If I'm off base, please
> feel free to let me know.
>
> I  have performed a test in both VS.NET 2003 and VS 2005, but couldn't
> reproduce the problem on either of them.
>
> In my test VS.NET 2003 project, I add a Menu to the MDI parent form, and
> add a MenuItem in the Menu. I set the MdiList property of the MenuItem to
> True.
>
> When the program is run and I open several MDI child forms, all the MDI
> child forms are listed under the MenuItem. When I close one of the MDI
> child forms, it disappears from the MDI child list and doesn't exist in
> the
> MdiChildren property of the MDI parent, either.
>
> In my test VS 2005 project, I add a MenuStrip on the MDI parent form and
> add a ToolStripMenuItem to the MenuStrip. I set the MdiWindowListItem
> property of the MenuStrip to the ToolStripMenuItem. When the program is
> run, the program behaves the same as my VS.NET 2003 test program does.
>
> Does this problem always exist when you close the MDI child form?
>
> Since I couldn't reproduce the problem on my side, it's hard for me to
> troubleshoot the problem. If possible, could you please send me a sample
> project that could just reproduce the problem? To get my actual email
> address, remove 'online' from my displayed email address.
>
> Sincerely,
> Linda Liu
> Microsoft Online Community Support
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>

AddThis Social Bookmark Button