Random exceptions on close

Docking/MDI for Windows Forms Forum

The latest build of this product (v24.1.0) was released 2 months ago, which was before this thread was created.
Posted 1 month ago by Tom Johnson
Version: 24.1.0
Avatar

On ToolWindows that are hidden, their Dispose method will randomly get an exception when the application is closed.   The exception is either null reference (which according to the debugger isn't valid) or cross-thread attempt (the window and dispose are both being called from the main thread).   v21.1 of the Docking does not exhibit this issue.  Any suggestions?

Comments (4)

Posted 1 month ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Tom,

I'm sorry you're having trouble.  We aren't aware of any issues in that area.  Can you make a new simple sample project that reproduces it and send it to our support address so we can debug what's going on and resolve the problem?  Be sure to reference this thread in your email and exclude the bin/obj folders in the .zip you send so that it doesn't get spam blocked.

If you're not able to reproduce in a sample project, is there a stack trace you can post?  Any additional information like the target framework (e.g., .NET Framework 4.8, .NET 8) would also be beneficial.  Please also let us know if this issue is only observed using the RemoteApp configuration you have recently posted about or if this is something you have reproduced when running locally.

Thanks!


Actipro Software Support

Posted 1 month ago by Tom Johnson
Avatar

I haven't been able to reproduce it with a simple app.   Here is the stack trace:

System.Windows.Forms.dll!System.Windows.Forms.ToolTip.RemoveAll() Unknown
System.Windows.Forms.dll!System.Windows.Forms.ToolTip.Dispose(bool disposing) Unknown
System.dll!System.ComponentModel.Component.Dispose() Unknown
System.dll!System.ComponentModel.Container.Dispose(bool disposing) Unknown
System.dll!System.ComponentModel.Container.Dispose() Unknown
OMNIClient.exe!OMNIClient.VolumeControl.Dispose(bool disposing) Line 22 C#
System.dll!System.ComponentModel.Component.Dispose() Unknown
ActiproSoftware.Docking.WinForms.dll!ActiproSoftware.UI.WinForms.Controls.Docking.DockManager.Dispose(bool disposing) Unknown
System.dll!System.ComponentModel.Component.Dispose() Unknown
System.dll!System.ComponentModel.Container.Dispose(bool disposing) Unknown
System.dll!System.ComponentModel.Container.Dispose() Unknown
OMNIClient.exe!OMNIClient.MainForm.Dispose(bool disposing) Line 18 C#
System.Windows.Forms.dll!System.Windows.Forms.Form.WmClose(ref System.Windows.Forms.Message m) Unknown
OMNIClient.exe!OMNIClient.MainForm.WndProc(ref System.Windows.Forms.Message m) Line 675 C#
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam) Unknown
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.Control.SendMessage(int msg, int wparam, int lparam) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Form.Close() Unknown
> OMNIClient.exe!OMNIClient.MainForm.ShutdownWorker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) Line 14079 C#
System.dll!System.ComponentModel.BackgroundWorker.OnRunWorkerCompleted(System.ComponentModel.RunWorkerCompletedEventArgs e) Unknown
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.Delegate.DynamicInvokeImpl(object[] args) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackDo(System.Windows.Forms.Control.ThreadMethodEntry tme) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(object obj) Unknown
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unknown
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unknown
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallback(System.Windows.Forms.Control.ThreadMethodEntry tme) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbacks() Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam) Unknown
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) Unknown
OMNIClient.exe!OMNIClient.Program.Main(string[] args) Line 509 C#

Posted 1 month ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Tom,

Thank you for the stack trace.  Just looking at the stack, it does not appear to be an issue directly related to our Docking controls. Yes, the docking controls are part of the Dispose process (as they should be), but the exception appears to be thrown by other controls that are perhaps being hosted within a ToolWindow or DocumentWindow.

Perhaps look at the Dispose method of the class identified by this part of the stack:

OMNIClient.exe!OMNIClient.VolumeControl.Dispose(bool disposing) Line 22

You mentioned in the original post that you sometimes have a cross-thread issue.  In your stack trace, I see that a background worker is involved:

OMNIClient.exe!OMNIClient.MainForm.ShutdownWorker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) Line 14079 C#
System.dll!System.ComponentModel.BackgroundWorker.OnRunWorkerCompleted(System.ComponentModel.RunWorkerCompletedEventArgs e) Unknown

Make sure that your logic is not executing on a background thread and call MainForm.Close from the UI thread.


Actipro Software Support

Posted 1 month ago by Tom Johnson
Avatar

It is the standard Dispose method in the FormDesigner.cs that Visual Studio generates.  Also, it does not happen when using the 21.1 version of the Docker controls.   However, maybe it is our code since in the window is visible when the app exits, the error does not occur.

Add Comment

Please log in to a validated account to post comments.