Designer crashes when running Visual Studio 17.3.0 as a DpiUnaware process where the project is set to SystemAware.
See original GitHub issueEnvironment
Microsoft Visual Studio Enterprise 2022 (64-bit) - Current Version 17.3.1
(The problem also exists in 17.3.0.)
.NET version
.NET 6.0
Did this work in a previous version of Visual Studio and/or previous .NET release?
Yes, worked in 17.0.x, 17.1.x and 17.2.x. Problem started with 17.3.0.
Issue description
I am using VS2022 for developing a Windows Forms app. Since my development computer has three screens, one at 200% Scale, one at 150% Scale and one at 100% Scale, I need to run VS in DpiUnaware mode; otherwise the Windows Forms Editor messes up.
To do this, I use a registry setting:
[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\devenv.exe"="DPIUNAWARE"
In accordance to: Disable DPI-awareness for scaling in forms - Visual Studio (Windows) | Microsoft Docs
If I start VS 17.3 with that registry setting, open my project (set to use the SystemAware DPI mode) and open a Form in the Windows Form Designer, the designer crashes:
[08:26:33.460454] warn: DPI mode SystemAware specified in the project is not compatible with Visual Studio process DPI mode DpiUnaware. Winforms designer will have DPI mode DpiUnaware
[08:26:33.535452] warn: DPI mode SystemAware specified in the project is not compatible with Visual Studio process DPI mode DpiUnaware. Winforms designer will have DPI mode DpiUnaware
[08:26:52.525974] fail: Exception occurred while disposing VSDesignSurface
System.InvalidOperationException: The service 'Microsoft.VisualStudio.Shell.Design.Serialization.DesignerDocDataService' must be installed for this feature to work. Ensure that this service is available.
at System.ServiceExtensions.GetRequiredService[TService,TInterface](IServiceProvider provider)
at Microsoft.DotNet.DesignTools.Client.CodeDom.CodeDomSource..ctor(IDesignerHost designerHost)
at Microsoft.DotNet.DesignTools.Client.Loader.VsDesignerLoader.<get_CodeDomSource>g__Create|37_0()
at Microsoft.DotNet.DesignTools.Client.Loader.VsDesignerLoader.get_CodeDomSource()
at Microsoft.DotNet.DesignTools.Client.Loader.VsDesignerLoader.get_CodeDomManager()
at Microsoft.DotNet.DesignTools.Client.Loader.VsDesignerLoader.OnBeginUnload()
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.UnloadDocument()
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.Dispose()
at Microsoft.DotNet.DesignTools.Client.Loader.VsDesignerLoader.Dispose()
at System.ComponentModel.Design.DesignerHost.DisposeHost()
at System.ComponentModel.Design.DesignSurface.Dispose(Boolean disposing)
at Microsoft.VisualStudio.WinForms.VSDesignSurface.Dispose(Boolean disposing)
For information on how to troubleshoot the designer refer to the guide at https://aka.ms/winforms/designer/troubleshooting.
I had to remove the registry setting.
Steps to reproduce
- Create the registry setting:
[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\devenv.exe"="DPIUNAWARE"
- Create a new Windows Forms project
- Set the ApplicationHighDpiMode to SystemAware:
<ApplicationHighDpiMode>SystemAware</ApplicationHighDpiMode>
- Open the Form in the Windows Forms Designer.
Diagnostics
`[08:26:33.460454] warn: DPI mode SystemAware specified in the project is not compatible with Visual Studio process DPI mode DpiUnaware. Winforms designer will have DPI mode DpiUnaware
[08:26:33.535452] warn: DPI mode SystemAware specified in the project is not compatible with Visual Studio process DPI mode DpiUnaware. Winforms designer will have DPI mode DpiUnaware
[08:26:52.525974] fail: Exception occurred while disposing VSDesignSurface
System.InvalidOperationException: The service 'Microsoft.VisualStudio.Shell.Design.Serialization.DesignerDocDataService' must be installed for this feature to work. Ensure that this service is available.
at System.ServiceExtensions.GetRequiredService[TService,TInterface](IServiceProvider provider)
at Microsoft.DotNet.DesignTools.Client.CodeDom.CodeDomSource..ctor(IDesignerHost designerHost)
at Microsoft.DotNet.DesignTools.Client.Loader.VsDesignerLoader.<get_CodeDomSource>g__Create|37_0()
at Microsoft.DotNet.DesignTools.Client.Loader.VsDesignerLoader.get_CodeDomSource()
at Microsoft.DotNet.DesignTools.Client.Loader.VsDesignerLoader.get_CodeDomManager()
at Microsoft.DotNet.DesignTools.Client.Loader.VsDesignerLoader.OnBeginUnload()
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.UnloadDocument()
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.Dispose()
at Microsoft.DotNet.DesignTools.Client.Loader.VsDesignerLoader.Dispose()
at System.ComponentModel.Design.DesignerHost.DisposeHost()
at System.ComponentModel.Design.DesignSurface.Dispose(Boolean disposing)
at Microsoft.VisualStudio.WinForms.VSDesignSurface.Dispose(Boolean disposing)
For information on how to troubleshoot the designer refer to the guide at https://aka.ms/winforms/designer/troubleshooting.
`
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Thanks!
Verified this issue on VS 17.4.0 Preview 2.0 build, this issue was fixed. When using registry key as following screenshot to set VS as DpiUnaware mode, the form designer loads successfully. Please Install the most recent release from https://visualstudio.microsoft.com/vs/preview/