Posted 13 November 2023, 10:16 am EST - Updated 13 November 2023, 10:21 am EST
Hi C1,
today, I observed several deadlocks in WinForms designer, which forced me to kill Visual Studio and reopen it.
It happens when I open a C1RibbonForm subclass and switch to another ribbon tab. I can do those steps for the first time without problems. But when I reopen the file another time and click in the ribbon, the lock occurs.
Unfortunately, I cannot reproduce it with a simple sample. So, hopefully you have an idea.
I attached another Visual Studio to “DesignToolsServer.exe” and found this stack trace where the ribbon designer seems to hang in a clipboard access:
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.Clipboard.GetDataObject(int retryTimes, int retryDelay) Line 135 C#
System.Windows.Forms.dll!System.Windows.Forms.Clipboard.GetDataObject() Line 123 C#
System.Windows.Forms.dll!System.Windows.Forms.Clipboard.ContainsData(string format) Line 189 C#
C1.Win.Ribbon.6.Design.Server.dll!C1.Win.Ribbon.Design.Server.Floaties.RibbonBaseFloatieOwner.GetActionItems(bool deleteButtonOnly) Unknown
C1.Win.Ribbon.6.Design.Server.dll!C1.Win.Ribbon.Design.Server.Floaties.TabFloatieOwner.GetItems() Unknown
C1.Win.6.Design.Server.dll!C1.Win.Design.Server.Floaties.FloatieService.CreateFloatieForm(C1.Win.Design.Server.Floaties.IFloatieOwner floatieOwner) Unknown
C1.Win.6.Design.Server.dll!C1.Win.Design.Server.Floaties.FloatieFormsBehavior.ShowForm() Unknown
C1.Win.6.Design.Server.dll!C1.Win.Design.Server.Floaties.FloatieGlyph.Paint(System.Windows.Forms.PaintEventArgs pe) Unknown
Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Designers.Behaviors.BehaviorService.PropagatePaint(System.Windows.Forms.PaintEventArgs pe) Unknown
Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Designers.Behaviors.BehaviorService.AdornerWindow.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) Line 2933 C#
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, Interop.User32.WM msg, System.IntPtr wparam, System.IntPtr lparam) Line 356 C#
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.Clipboard.GetDataObject(int retryTimes, int retryDelay) Line 135 C#
System.Windows.Forms.dll!System.Windows.Forms.Clipboard.GetDataObject() Line 123 C#
System.Windows.Forms.dll!System.Windows.Forms.Clipboard.ContainsData(string format) Line 189 C#
C1.Win.Ribbon.6.Design.Server.dll!C1.Win.Ribbon.Design.Server.Floaties.RibbonBaseFloatieOwner.GetActionItems(bool deleteButtonOnly) Unknown
C1.Win.Ribbon.6.Design.Server.dll!C1.Win.Ribbon.Design.Server.Floaties.TabFloatieOwner.GetItems() Unknown
C1.Win.6.Design.Server.dll!C1.Win.Design.Server.Floaties.FloatieService.CreateFloatieForm(C1.Win.Design.Server.Floaties.IFloatieOwner floatieOwner) Unknown
C1.Win.6.Design.Server.dll!C1.Win.Design.Server.Floaties.FloatieFormsBehavior.ShowForm() Unknown
C1.Win.6.Design.Server.dll!C1.Win.Design.Server.Floaties.FloatieGlyph.Paint(System.Windows.Forms.PaintEventArgs pe) Unknown
Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Designers.Behaviors.BehaviorService.PropagatePaint(System.Windows.Forms.PaintEventArgs pe) Unknown
Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Designers.Behaviors.BehaviorService.AdornerWindow.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) Line 2933 C#
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, Interop.User32.WM msg, System.IntPtr wparam, System.IntPtr lparam) Line 356 C#
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.Primitives.dll!Interop.User32.UpdateWindow(IHandle hWnd) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.Update() Line 13231 C#
Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Designers.Behaviors.BehaviorService.AdornerWindow.InvalidateAdornerWindow(System.Drawing.Rectangle rectangle) Unknown
C1.Win.6.Design.Server.dll!C1.Win.Design.Server.Floaties.FloatieGlyph.InvalidateOwnerLocation() Unknown
C1.Win.6.Design.Server.dll!C1.Win.Design.Server.Floaties.FloatieGlyph.IsVisible.set(bool value) Unknown
C1.Win.6.Design.Server.dll!C1.Win.Design.Server.Floaties.FloatieService.a() Unknown
C1.Win.6.Design.Server.dll!C1.Win.Design.Server.Floaties.FloatieService.a(object A_0, System.EventArgs A_1) Unknown
Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Host.RemoteSelectionService.OnSelectionChanged() Unknown
Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Host.RemoteSelectionService.UpdateSelection(System.Collections.Generic.IEnumerable<System.ComponentModel.IComponent> components, System.ComponentModel.Design.SelectionTypes selectionType) Unknown
Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Host.RemoteSelectionService.SetSelectedComponents(System.Collections.Generic.IEnumerable<System.ComponentModel.IComponent> components, System.ComponentModel.Design.SelectionTypes selectionType) Unknown
C1.Win.Ribbon.6.Design.Server.dll!C1.Win.Ribbon.Design.Server.Designers.C1RibbonDesigner.dq.SelectComponent(System.ComponentModel.Component component) Unknown
C1.Win.Ribbon.6.dll!bk.OnClick() Unknown
C1.Win.6.dll!C1.Framework.ButtonElement.PerformClick() Unknown
C1.Win.Ribbon.6.Design.Server.dll!C1.Win.Ribbon.Design.Server.Glyphs.SelectionBehavior.OnMouseDown(Microsoft.DotNet.DesignTools.Designers.Behaviors.Glyph g, System.Windows.Forms.MouseButtons button, System.Drawing.Point mouseLoc) Unknown
Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Designers.Behaviors.BehaviorService.Microsoft.DotNet.DesignTools.Designers.IInputDispatcher.OnMouseDown(Microsoft.DotNet.DesignTools.Designers.MouseDispatchEventArgs e) Unknown
Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Designers.Behaviors.BehaviorService.AdornerWindow.ProxyDispatcher.OnMouseDown(Microsoft.DotNet.DesignTools.Designers.MouseDispatchEventArgs e) Unknown
Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Designers.InputDispatcher.OnMouseDown(Microsoft.DotNet.DesignTools.Designers.MouseDispatchEventArgs e) Unknown
Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Designers.ScrollableControlDispatcher.OnMouseDown(Microsoft.DotNet.DesignTools.Designers.MouseDispatchEventArgs e) Unknown
Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Designers.DesignerFrame.Dispatcher.OnMouseDown(Microsoft.DotNet.DesignTools.Designers.MouseDispatchEventArgs e) Unknown
Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Protocol.Endpoints.Input.InputMessageHandler.HandleRequest(Microsoft.DotNet.DesignTools.Protocol.Endpoints.Input.InputMessageRequest request) Unknown
Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Protocol.Endpoints.RequestHandler<Microsoft.DotNet.DesignTools.Protocol.Endpoints.Input.InputMessageRequest, Microsoft.DotNet.DesignTools.Protocol.Endpoints.Input.InputMessageResponse>.Microsoft.DotNet.DesignTools.Protocol.Endpoints.IRequestHandler.HandleRequest(Microsoft.DotNet.DesignTools.Protocol.Endpoints.Request request) Unknown
Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Protocol.Endpoints.RequestManager.HandleRequestAsync(string name, Microsoft.DotNet.DesignTools.Protocol.Endpoints.Request request) Unknown
[Resuming Async Method]
System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<Microsoft.DotNet.DesignTools.Protocol.Endpoints.Response>.AsyncStateMachineBox<Microsoft.DotNet.DesignTools.Protocol.Endpoints.RequestManager.<HandleRequestAsync>d__10>.MoveNext(System.Threading.Thread threadPoolThread) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(object obj) Line 9656 C#
System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbacks() Line 9733 C#
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) Line 14480 C#
System.Windows.Forms.dll!System.Windows.Forms.ScrollableControl.WndProc(ref System.Windows.Forms.Message m) Line 1462 C#
System.Windows.Forms.dll!System.Windows.Forms.Form.WndProc(ref System.Windows.Forms.Message m) Line 5617 C#
Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Server.Window.ServerWindow.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) Line 2933 C#
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, Interop.User32.WM msg, System.IntPtr wparam, System.IntPtr lparam) Line 356 C#
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.Interop.Mso.IMsoComponentManager.FPushMessageLoop(System.UIntPtr dwComponentID, Interop.Mso.msoloop uReason, void* pvLoopData) Line 236 C#
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Interop.Mso.msoloop reason, System.Windows.Forms.ApplicationContext context) Line 1318 C#
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Interop.Mso.msoloop reason, System.Windows.Forms.ApplicationContext context) Line 1236 C#
System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.ApplicationContext context) Line 2744 C#
Microsoft.DotNet.DesignTools.Server.dll!Microsoft.DotNet.DesignTools.Server.DesignToolsServer.StartUIThreadAsync.AnonymousMethod__1() Unknown
System.Private.CoreLib.dll!System.Threading.Thread.StartHelper.Callback(object state) Unknown
System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown
System.Private.CoreLib.dll!System.Threading.Thread.StartCallback() Unknown
[Async Call Stack]
[Async] StreamJsonRpc.dll!StreamJsonRpc.JsonRpc.DispatchIncomingRequestAsync(StreamJsonRpc.Protocol.JsonRpcRequest request) Unknown
[Async] StreamJsonRpc.dll!StreamJsonRpc.JsonRpc.HandleRpcAsync(StreamJsonRpc.Protocol.JsonRpcMessage rpc) Unknown
As you can see, the clipboard seems to be locked. Today, I work from home through a RDP session - maybe this is related. But Clipboard copy/paste works as usual, besides this lock.
The clipboard access seems to do a retry internally and throw an exception. But maybe this delay causes a reentrant behavior, as the clipboard access happens in a “Paint” method? Probably, it is not a good idea to to something like this ;-).
Best regards
Wolfgang