-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
.NET version
6.0.3
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
Worked without any issues in NET 5 and Net Framework
Issue description
In a WinForms desktop application targeting .NET 6, the [UseWindowsForms] element in the .proj file is set to True, and a bootstrap ApplicationConfiguration.Initialize(); is generated and called from the startup file Program.
Now I want to enable WPF by setting [EnableWPF] to True. When I do that and build I get the following error in the output log
Program.cs(13,13,13,37): error CS0103: The name 'ApplicationConfiguration' does not exist in the current context 1>Done building project "WinFormsApp1_s2dcxfug_wpftmp.csproj" -- FAILED.
My workaround for a net6 WinForm Project with WPF Enabled is editing the Program.CS to code below
//ApplicationConfiguration.Initialize(); Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1());
Steps to reproduce
To Reproduce
- Create a new Windows Forms project in VS 2022 targeting .NET 6.
- Go to proj properties and check the Enable WPF for this project check box
- Add a WPF window to the project
- Build