Hi Eric,
Thanks for your feedback.
Yes, with your sample project, I can reproduce out this problem.
I think you are right. If we enable first chance exception in VS2005 after
setting up the symbol correctly. We will get the following call stack
because of the ObjectDisposedE xception:
System.Windows. Forms.dll!Syste m.Windows.Forms .Control.Create Handle() Line
5581 + 0x2a bytes C#
System.Windows. Forms.dll!Syste m.Windows.Forms .ToolStripDropD own.CreateHandl e
() Line 1143 C#
System.Windows. Forms.dll!Syste m.Windows.Forms .Control.Handle .get() Line
2743 C#
System.Windows. Forms.dll!Syste m.Windows.Forms .ToolStripDropD own.ReparentToD r
opDownOwnerWind ow() Line 1657 + 0xb bytes C#
System.Windows. Forms.dll!Syste m.Windows.Forms .ToolStripDropD own.SetVisibleC o
re(bool visible = false) Line 1913 C#
System.Windows. Forms.dll!Syste m.Windows.Forms .ToolStripDropD own.OnItemClick e
d(System.Window s.Forms.ToolStr ipItemClickedEv entArgs e =
{System.Windows .Forms.ToolStri pItemClickedEve ntArgs}) Line 1358 + 0x19
bytes C#
System.Windows. Forms.dll!Syste m.Windows.Forms .ToolStrip.Hand leItemClick(Sys t
em.Windows.Form s.ToolStripItem dismissingItem = {Close}) Line 2582 C#
System.Windows. Forms.dll!Syste m.Windows.Forms .ToolStripItem. HandleClick(Sys t
em.EventArgs e = {System.EventAr gs}) Line 2769 C#
System.Windows. Forms.dll!Syste m.Windows.Forms .ToolStripItem. HandleMouseUp(S y
stem.Windows.Fo rms.MouseEventA rgs e = {X = 30 Y = 15 Button = Left}) Line
2920 C#
System.Windows. Forms.dll!Syste m.Windows.Forms .ToolStripItem. FireEventIntera c
tive(System.Eve ntArgs e, System.Windows. Forms.ToolStrip ItemEventType met)
Line 2626 C#
System.Windows. Forms.dll!Syste m.Windows.Forms .ToolStripItem. FireEvent(Syste m
.EventArgs e, System.Windows. Forms.ToolStrip ItemEventType met) Line 2607 C#
System.Windows. Forms.dll!Syste m.Windows.Forms .ToolStrip.OnMo useUp(System.Wi n
dows.Forms.Mous eEventArgs mea) Line 3531 + 0xd bytes C#
System.Windows. Forms.dll!Syste m.Windows.Forms .ToolStripDropD own.OnMouseUp(S y
stem.Windows.Fo rms.MouseEventA rgs mea = {X = 30 Y = 17 Button = Left}) Line
1439 C#
System.Windows. Forms.dll!Syste m.Windows.Forms .Control.WmMous eUp(ref
System.Windows. Forms.Message m, System.Windows. Forms.MouseButt ons button,
int clicks) Line 13032 + 0x5e bytes C#
System.Windows. Forms.dll!Syste m.Windows.Forms .Control.WndPro c(ref
System.Windows. Forms.Message m) Line 13762 C#
System.Windows. Forms.dll!Syste m.Windows.Forms .ScrollableCont rol.WndProc(ref
System.Windows. Forms.Message m) Line 1491 C#
System.Windows. Forms.dll!Syste m.Windows.Forms .ToolStrip.WndP roc(ref
System.Windows. Forms.Message m = {msg=0x202 (WM_LBUTTONUP) hwnd=0x109c0
wparam=0x0 lparam=0x11001e result=0x0}) Line 4627 C#
System.Windows. Forms.dll!Syste m.Windows.Forms .ToolStripDropD own.WndProc(ref
System.Windows. Forms.Message m) Line 2112 C#
System.Windows. Forms.dll!Syste m.Windows.Forms .Control.Contro lNativeWindow.O n
Message(ref System.Windows. Forms.Message m) Line 14049 C#
System.Windows. Forms.dll!Syste m.Windows.Forms .Control.Contro lNativeWindow.W n
dProc(ref System.Windows. Forms.Message m) Line 14104 C#
System.Windows. Forms.dll!Syste m.Windows.Forms .NativeWindow.D ebuggableCallba c
k(System.IntPtr hWnd, int msg = 514, System.IntPtr wparam, System.IntPtr
lparam) Line 777 + 0xa bytes C#
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows. Forms.dll!Syste m.Windows.Forms .Application.Co mponentManager. S
ystem.Windows.F orms.UnsafeNati veMethods.IMsoC omponentManager .FPushMessageLo o
p(int dwComponentID, int reason = -1, int pvLoopData = 0) Line 2106 + 0x8
bytes C#
System.Windows. Forms.dll!Syste m.Windows.Forms .Application.Th readContext.Run M
essageLoopInner (int reason = -1, System.Windows. Forms.Applicati onContext
context = {System.Windows .Forms.Applicat ionContext}) Line 3359 + 0x1b bytes
C#
System.Windows. Forms.dll!Syste m.Windows.Forms .Application.Th readContext.Run M
essageLoop(int reason, System.Windows. Forms.Applicati onContext context)
Line 3243 + 0xa bytes C#
System.Windows. Forms.dll!Syste m.Windows.Forms .Application.Ru n(System.Window s
.Forms.Form mainForm) Line 1466 C#
MenuCrashSample .exe!MenuCrashS ample.Program.M ain() Line 17 + 0x1a bytes C#
With Reflector, we will find the following code in
System.Windows. Forms.Control.C reateHandle() method:
protected virtual void CreateHandle()
{
IntPtr ptr1 = IntPtr.Zero;
if (this.GetState( 0x800))
{
throw new ObjectDisposedE xception(base.G etType().Name);
}
.....
}
Then by using Reflector to view Control.Dispose method, we will see the
following code in finally clause:
finally
{
this.ResumeLayo ut(false);
this.SetState(0 x1000, false);
this.SetState(0 x800, true);
}
So, Control.Dispose () method turn on 0x800 flag, which causes
ObjectDisposedE xception in System.Windows. Forms.Control.C reateHandle()
method.
Currently, I think your workaround of using mnuFile.DropDow n.Hide() should
be a good one. Also, you may submit a bug request to our product team in
the link below:
http://lab.msdn.microsoft.com/produc...k/default.aspx
Thanks
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.