Subscribing to touch manager events is setting the Stylus.IsPressAndHoldEnabled attached property on the associated element to False. However, the property is not set back to True, after you remove the TouchManager event handlers from the element. Therefore, the default tap and hold action that displays the rectangular shape over the element is no longer executed.
To work this around set the Stylus.IsPressAndHoldEnabled attached property manually.
DragDropManager.RemoveDragInitializeHandler(element, OnDragInitialized);
Stylus.SetIsPressAndHoldEnabled(element, true);
The exception occurs when publishing .NET 9 application and the "Deployment Mode" in the "Publish profile" is set to "Self-contained".
The exception is not displayed, but instead the application crashes at startup and it seems like it cannot start at all. You can see the error in the Events Viewer tool of the Windows OS, after you navigate to the "Windows Logs-->Application" menu.
This is not reproducible in .NET 8.
The original stacktrace where this was hit is the following:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Windows.Forms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified. File name: 'System.Windows.Forms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' at Telerik.Windows.Input.Touch.TouchManager.InitializeProperties() at Telerik.Windows.Input.Touch.TouchManager.RemoveTapHoldAndReleaseEventHandler(UIElement element, TouchEventHandler handler) at Telerik.Windows.Controls.RadContextMenu.AttachHandler(UIElement element) at Telerik.Windows.Controls.RadContextMenu.CreateReferences(UIElement element)
To work this around, you can try one of the following ideas: