DPIAwareness: ArgumentException when opening a ContextMenuStrip
See original GitHub issue-
.NET Core Version: 3.1.0
-
Have you experienced this same bug with .NET Framework?: No
Problem description:
We are experiencing the following crashreports from some users when they open a contextMenu. All reports originate from Windows10 (version 1607 - build 14393 or later), but we are not able to simulate it on our side.
System.Windows.Forms.System.ArgumentException: dpiContext (Parameter 'DPI_AWARENESS_CONTEXT_UNSPECIFIED')
at System.Windows.Forms.CommonUnsafeNativeMethods.TrySetThreadDpiAwarenessContext
at System.Windows.Forms.DpiHelper+DpiAwarenessScope.Dispose
at System.Windows.Forms.ToolStripManager+ModalMenuFilter.PreFilterMessage
at System.Windows.Forms.Application+ThreadContext.ProcessFilters
at System.Windows.Forms.Application+ThreadContext.PreTranslateMessage
at System.Windows.Forms.Application+ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FPreTranslateMessage
at System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop
at System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner
at System.Windows.Forms.Application+ThreadContext.RunMessageLoop
at System.Windows.Forms.Application.Run
our app is PerMonitorV2 aware as defined in app.manifest:
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
</asmv3:windowsSettings>
</asmv3:application>
Issue Analytics
- State:
- Created 4 years ago
- Comments:18 (18 by maintainers)
Top Results From Across the Web
ContextMenuStrip doesn't DPI scale when Form is dragged ...
The ContextMenuStrip doesn't scale when its parent Form is dragged between monitors of different resolution/scaling. The ContextMenuStrip is ...
Read more >How to: Handle the ContextMenuStrip Opening Event - ...
The following code example demonstrates how to handle the Opening event. The event handler adds items dynamically to a ContextMenuStrip control.
Read more >sitemap-feedback-posts.xml
... https://www.syncfusion.com/feedback/64/argumentexception-occurs-while- ... -functionality-to-highlight-the-matching-open-and-close-brackets-in-wpf ...
Read more >ComponentSource News | Data Editor Components
The sample displays open, high, low, close, and volume of a stock, ... ArgumentException "Parameter is not valid" when saving editor changes and ......
Read more >Viewing online file analysis results for 'mywifi.exe'
Opened the service control manager ... <windowsSettings> <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/Windo.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Unfortunately the self-contained output is kind of on the big side so I had to share it through external service that allows larger files.
https://send.firefox.com/download/b48739bcf3c1097f/#4aBM9eavZZCiGZsTYQPuPg
The link will be valid for a week, or 100 downloaded, whichever comes first. I can reupload it elsewhere if it becomes an issue.
I think we are going to take this for .NET 5, but for 3.1 I don’t think we’re going to take it until/unless we can determine that there is a repro that we could expect to hit occasionally. If you could provide the binary again, if we inspect it in ILSpy and find a more common repro I’ll happily reconsider this for 3.1.