ErrorProvider exception when shown a second time after being dragged on another monitor with diiferent DPI #12850
Labels
area-HDPI
HDPI, not specific to Dpi mode of app
💥 regression-release
Regression from a public release
Milestone
.NET version
8.0.12
Did it work in .NET Framework?
Not tested/verified
Did it work in any of the earlier releases of .NET Core or .NET 5+?
Yes:
7.0.20
9.0.0
Issue description
ErrorProvider throws this exception, when displayed for the second time in a Form, which was previously dragged into another monitor with different DPI.
Cannot access a disposed object.
Object name: 'Icon'.
at System.Drawing.Icon.get_Handle()
at System.Windows.Forms.ErrorProvider.IconRegion.get_Handle()
at Windows.Win32.PInvoke.DrawIconEx[T](HDC hDC, Int32 xLeft, Int32 yTop, T hIcon, Int32 cxWidth, Int32 cyWidth)
at System.Windows.Forms.ErrorProvider.ErrorWindow.OnPaint()
at System.Windows.Forms.ErrorProvider.ErrorWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam)
Note that for the bug to happen, the application HighDpiMode must be set to PerMonitorV2 AND the ErrorProvider object must not have it's Icon property set with a Icon object.
Steps to reproduce
An application sample is attached.
ErrorProviderBug.zip
To reproduce with the example (requires at least two monitors with different DPIs):
In the sample application, I commented in Form2.cs a set on the property Icon of the errorProvider object, so that you can experiment that if we use a custom Icon, and redo the steps above, the bug won't happen. Same if you set a HighDpiMode other than PerMonitorV2 in Program.cs.
The text was updated successfully, but these errors were encountered: