Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tinodo opened this issue Aug 18, 2022 · 5 comments
Assignees
Labels
area-VSDesigner Windows Forms out-of-proc designer related issues

Comments

@tinodo
Copy link

tinodo commented Aug 18, 2022

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.
`
@tinodo tinodo added area-VSDesigner Windows Forms out-of-proc designer related issues untriaged The team needs to look at this issue in the next triage labels Aug 18, 2022
@Olina-Zhang
Copy link
Member

Olina-Zhang commented Aug 18, 2022

I can reproduce this issue when using registry key as following screenshot to set VS as DpiUnaware mode, the form designer cannot be loaded with or without the addition of appllication's DPI: <ApplicationHighDpiMode>SystemAware</ApplicationHighDpiMode>
image

  • without application's DPI, form designer loads failed with showing "Timed out while connecting to named pipe"
  • then add application's DPI, form designer loads failed with same showing "Timed out while connecting to named pipe"
[17:08:47.578075] fail: [WinFormsApp24]: Failed to launch design tools server process process
                        System.InvalidOperationException: Failed to set process DPI mode value to: DpiUnaware.
                           at Microsoft.WinForms.Utilities.Desktop.DpiHelper.SetDesignerProcessDpiAwareness(HighDpiMode highDpiMode) in E:\workspace\Microsoft\winforms-designer\src\Utilities.Desktop\DpiHelper.cs:line 361
                           at Microsoft.DotNet.DesignTools.Server.Program.<>c__DisplayClass2_0.<<Main>b__1>d.MoveNext() in E:\workspace\Microsoft\winforms-designer\src\Microsoft.DotNet.DesignTools.Server\Server\Program.cs:line 70

but this issue cannot reproduce using command line to launch VS as DpiUnaware mode: devenv /noScale

  • without application's DPI, form designer loads successfully
  • then add application's DPI, form designer loads successfully
    image

@tinodo
Copy link
Author

tinodo commented Aug 18, 2022

That is correct. You have to remove the registry setting and use the /noScale parameter for DevEnv.exe or set your displays to 100% or wait for the 'warning' in Visual Studio to appear and click the provided link in the warning to restart VS as a DpiUnaware process.
For me, the registry setting was the preferred solution; I might 'forget' the /noScale and I don't want to change the DPI settings on my monitors.

Hope it will be possible again soon to use the registry setting!

@dreddy-work
Copy link
Member

Looking into it.

@dreddy-work dreddy-work self-assigned this Aug 18, 2022
@dreddy-work dreddy-work removed the untriaged The team needs to look at this issue in the next triage label Aug 18, 2022
@Ashley-Li
Copy link

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/

@tinodo
Copy link
Author

tinodo commented Sep 15, 2022

Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Oct 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-VSDesigner Windows Forms out-of-proc designer related issues
Projects
None yet
Development

No branches or pull requests

4 participants