question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Designer crashes when running Visual Studio 17.3.0 as a DpiUnaware process where the project is set to SystemAware.

See original GitHub issue

Environment

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

  1. 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"
  2. Create a new Windows Forms project
  3. Set the ApplicationHighDpiMode to SystemAware: <ApplicationHighDpiMode>SystemAware</ApplicationHighDpiMode>
  4. 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:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
tinodocommented, Sep 15, 2022

Thanks!

0reactions
Ashley-Licommented, Sep 15, 2022

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. image image Please Install the most recent release from https://visualstudio.microsoft.com/vs/preview/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix DPI display issues in Windows Form Designer - Visual ...
In this article. Windows Forms Designer is DPI-unaware; Restart Visual Studio as a DPI-unaware process; Use Windows to set your display scaling ......
Read more >
Visual Studio Crashes when trying to view designer
Go to Debug-> Options menu, under Debugging in the left had side pane, select “General” and in the right hand side pane ,...
Read more >
Visual Studio 2022 in multi-dpi environment: constant crash
I start VS2022 on the primary screen with WinForms dotnet7 project, and it keeps crashing. In the WinForms log, there are a few...
Read more >
Visual studio 2022 crash on start debugging
1 Answer 1 · you could locate to the IDE folder then run these commands, or you can set path to the system...
Read more >
Disable scaling issues with Windows Forms Designer in ...
When Visual Studio runs as a DPI-unaware process, the designer layout issues ... Set your display scaling setting to 100% A third option...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found