Control.Dispose hangs in SelectNextControl

U

Urs Eichmann

Hello
Situation: WinForms 1.1 application has three Non-Modal Forms being
shown at the same time:
- formA is the main form (started with Application.Run)
- formB has an ActiveX control on it and is minimized
- formC is an ordinary form, which is activated

formC now wants to close formB using formB.Dispose. somewhere in the
Dispose method of formB, the ActiveX control gets disposed too.

The system now hangs with 100 % cpu time on the call to Dispose of the
ActiveX control. The system seems to perform and endless loop in
SelectNextControl. It repeadly calls GetNextControl and CanSelect, but
never gets out of this loop.

This is reproducable behaviour within my application - but can't be
reproduced in a simpler sample app. Also, it only hangs if formC is of a
certain type (one which implements a wizard) - if it's of a simpler
type, there is no hang.

If anybody has experienced this already and knows a workaround or a
patch, please help.

I noticed that another guy had this problem (see
http://groups.google.ch/[email protected]&rnum=1)
But he never got an answer.

Thanks for any help
Urs Eichmann


The call stack of the hang is as follows:

system.windows.forms.dll!System.Windows.Forms.Control.SelectNextControl(System.Windows.Forms.Control
ctl = {PRISMA.BOBJ.Client.ConnectedPanels.TitleSaveAndCancelButton},
bool forward = true, bool tabStopOnly = true, bool nested = true, bool
wrap = true) + 0x49 bytes

system.windows.forms.dll!System.Windows.Forms.ContainerControl.AfterControlRemoved(System.Windows.Forms.Control
control = {AxPrismaDSOFramer.AxFramerControl}) + 0xf6 bytes

system.windows.forms.dll!System.Windows.Forms.Control.ControlCollection.Remove(System.Windows.Forms.Control
value = {AxPrismaDSOFramer.AxFramerControl}) + 0x13b bytes
system.windows.forms.dll!System.Windows.Forms.Control.Dispose(bool
disposing = true) + 0x287 bytes
system.windows.forms.dll!System.Windows.Forms.AxHost.Dispose(bool
disposing = true) + 0x2b bytes
system.dll!System.ComponentModel.Component.Dispose() + 0xf bytesprisma.tools.officedocument.dll!PRISMA.Tools.OfficeDocument.WordDocument.Dispose(Boolean
disposing = True) Line 988 + 0x17 bytes Basic

system.dll!System.ComponentModel.Component.Dispose() + 0xf bytes

prisma.bobj.client.dll!PRISMA.BOBJ.Client.ConnectedControls.ConnectedWordDocument.Dispose(Boolean
disposing = True) Line 204 + 0x17 bytes Basic
system.dll!System.ComponentModel.Component.Dispose() + 0xf bytes

prisma.bobj.client.dll!PRISMA.BOBJ.Client.Bases.BaseInputPanel.Dispose(Boolean
disposing = True) Line 808 + 0xb bytes Basic

prisma.bobj.client.dll!PRISMA.BOBJ.Client.Office.Panels.Panel_BaseDok.Dispose(Boolean
disposing = True) Line 65 + 0xb bytes Basic
system.dll!System.ComponentModel.Component.Dispose() + 0xf bytes

prisma.bobj.client.dll!PRISMA.BOBJ.Client.Bases.BaseConnectedInputPanel.RemoveInputPanel(Boolean
vRaiseEvents = True) Line 601 + 0x18 bytes Basic

prisma.bobj.client.dll!PRISMA.BOBJ.Client.Bases.BaseConnectedInputPanel.Dispose(Boolean
disposing = True) Line 202 + 0xf bytes Basic

prisma.bobj.client.dll!PRISMA.BOBJ.Client.ConnectedPanels.TitleAndSaveButton.Dispose(Boolean
disposing = True) Line 80 + 0xb bytes Basic

prisma.bobj.client.dll!PRISMA.BOBJ.Client.ConnectedPanels.TitleSaveAndCancelButton.Dispose(Boolean
disposing = True) Line 44 + 0xb bytes Basic
system.dll!System.ComponentModel.Component.Dispose() + 0xf bytes

prisma.bobj.client.dll!PRISMA.BOBJ.Client.Forms.fDialogBObjectDetail.Dispose(Boolean
disposing = True) Line 280 + 0x17 bytes Basic
system.dll!System.ComponentModel.Component.Dispose() + 0xf bytes

prisma.bobj.client.dll!PRISMA.BOBJ.Client.Office.Panels.Panel_BaseDok.CheckForActiveInstance()
Line 215 + 0xa bytes Basic

prisma.alim2000.dll!PRISMA.Alim2000.Dokumente.Tools.DokumentDisplayer.CreateInstance(PRISMA.BOBJ.Shared.DataStructures.TransferBObjectTypeAndKey
vParent = {PRISMA.BOBJ.Shared.DataStructures.TransferBObjectTypeAndKey},
String vVorlageID = "VKTOAUSZ", Boolean vUnique = False) Line 47 + 0x6
bytes Basic

prisma.alim2000.registerabfrage.dll!PRISMA.Alim2000.Register.Registerabfrage.RegisterAbfrageInputPanel.ShowPrintedDocument(DevComponents.DotNetBar.ButtonItem
vPrintButton = {DevComponents.DotNetBar.ButtonItem}) Line 489 + 0x45
bytes Basic

prisma.alim2000.registerabfrage.dll!PRISMA.Alim2000.Register.Registerabfrage.RegisterAbfrageInputPanel.Toolbar_ButtonItemClick(DevComponents.DotNetBar.ButtonItem
vButtonItem = {DevComponents.DotNetBar.ButtonItem}) Line 680 + 0xc
bytes Basic

prisma.alim2000.registerabfrage.dll!PRISMA.Alim2000.Register.Registerabfrage.Internal.RegisterabfrageToolbar.cDotNetBarManager_ItemClick(Object
sender = {DevComponents.DotNetBar.ButtonItem}, System.EventArgs e =
{System.EventArgs}) Line 442 + 0x2b bytes Basic

devcomponents.dotnetbar.dll!DevComponents.DotNetBar.DotNetBarManager.C0(DevComponents.DotNetBar.BaseItem
1F5 = {DevComponents.DotNetBar.ButtonItem}) + 0x38 bytes

devcomponents.dotnetbar.dll!DevComponents.DotNetBar.BaseItem.RaiseClick()
+ 0x20b bytes

devcomponents.dotnetbar.dll!DevComponents.DotNetBar.BaseItem.InternalMouseUp(System.Windows.Forms.MouseEventArgs
objArg = {X=32 Y=11 Button=Left}) + 0x13d bytes

devcomponents.dotnetbar.dll!DevComponents.DotNetBar.PopupItem.InternalMouseUp(System.Windows.Forms.MouseEventArgs
objArg = {X=32 Y=11 Button=Left}) + 0x2e bytes

devcomponents.dotnetbar.dll!DevComponents.DotNetBar.ButtonItem.InternalMouseUp(System.Windows.Forms.MouseEventArgs
objArg = {X=32 Y=11 Button=Left}) + 0x4f3 bytes

devcomponents.dotnetbar.dll!DevComponents.DotNetBar.MenuPanel.OnMouseUp(System.Windows.Forms.MouseEventArgs
e = {X=32 Y=11 Button=Left}) + 0x26 bytes

system.windows.forms.dll!System.Windows.Forms.Control.WmMouseUp(System.Windows.Forms.Message
m = {System.Windows.Forms.Message}, System.Windows.Forms.MouseButtons
button = Left, int clicks = 1) + 0x261 bytes

system.windows.forms.dll!System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message
m = {System.Windows.Forms.Message}) + 0x49b bytes

devcomponents.dotnetbar.dll!DevComponents.DotNetBar.MenuPanel.WndProc(System.Windows.Forms.Message
m = {System.Windows.Forms.Message}) + 0x50 bytes

system.windows.forms.dll!ControlNativeWindow.OnMessage(System.Windows.Forms.Message
m = {System.Windows.Forms.Message}) + 0x13 bytes

system.windows.forms.dll!ControlNativeWindow.WndProc(System.Windows.Forms.Message
m = {System.Windows.Forms.Message}) + 0xda bytes

system.windows.forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(int
hWnd = 3804468, int msg = 514, int wparam = 0, int lparam = 720928) +
0x3d bytes

system.windows.forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(int
dwComponentID = 2, int reason = -1, int pvLoopData = 0) + 0x349 bytes
system.windows.forms.dll!ThreadContext.RunMessageLoopInner(int reason
= -1, System.Windows.Forms.ApplicationContext context =
{System.Windows.Forms.ApplicationContext}) + 0x1f3 bytes
system.windows.forms.dll!ThreadContext.RunMessageLoop(int reason =
-1, System.Windows.Forms.ApplicationContext context =
{System.Windows.Forms.ApplicationContext}) + 0x50 bytes

system.windows.forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form
mainForm = {PRISMA.Alim2000.WinApp.fMain}) + 0x34 bytes
Alim2000.exe!PRISMA.Alim2000.WinApp.Main.Main() Line 105 + 0x9 bytes
Basic
 
Y

Ying-Shen Yu[MSFT]

Hi Eichmann,

From the calling stack, it seems the SelectedNextControl could not find a
valid control to activate.
It's still unclear what caused this behavior, to further investigate this
issue, a sample is needed to reproduce this problem, so that I can do some
debugging with it.

However since this problem could not be reproduced in simple project. We
may try some other ways to work around this code path.

First , you may try call Close method on FormB instead of calling Dispose
method directly,
calling Close method on a modeless form will dispose the form automatically.

If the problem still persists, you may try handling the FormClosed event ,
remove the ActiveX control from the Form.Controls collection and Dispose it
manually.

If the problem still persists and the call stack shows it's dead looping in
the same place, probably we need investigate deeper into the cause of the
dead loop.
If you are able to successfully seperate this problem into a simple sample
project , please feel free to send it to my mailbox to let me have a look.

Thanks!
Best regards,

Ying-Shen Yu [MSFT]
Microsoft Community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
U

Urs Eichmann

Hi Ying-Shen

Thanks for the quick response. I was able to get rid of the problem. The
problem seemed to be that another component called Dispose of its
subcontrols in the parent form's Closing event, instead of waiting for
it's own Dispose being called - funnily this was a workaround for
another .NET problem which we had in 1.0 and which is solved today. Now
it seems to work OK. BTW I had a look at the SelectNextControl code
using the Reflector disassembler. It is indeed possible that this code
loops forever - perhaps it should use an "emergency exit" by
implementing a counter which exists when it reaches 10000 loop
iterations? Just an idea from a humble .net programmer...

Best regards
Urs
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top