.NET Core Version: (e.g. 3.0 Preview1, or daily build number, use dotnet --info)
Microsoft.NETCore.App 3.0.0-preview7-27912-14 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0-preview7-27912-14 [C:Program FilesdotnetsharedMicrosoft.WindowsDesktop.App]
Windows version: (winver)
Windows 10
Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes/No
N/A
Problem description:
I used to be able to use the Win Forms folder dialog in .NET Core 3.0 Preview version WPF app, like this:
System.Windows.Forms.FolderBrowserDialog folderBrowserDialog;
But with latest .NET Core 3.0 Preview version I get compiler error.
Actual behavior:
I get this compiler error:
error CS0234: The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)
Expected behavior:
No error
Minimal repro:
Create new .NET Core WPF app and update MainWindow constructor like this:
public MainWindow()
{
InitializeComponent();
System.Windows.Forms.FolderBrowserDialog folderBrowserDialog;
}
Make sure you have this in your csproj file:
<PropertyGroup>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
Thanks that fixed it!
Thanks, it fixed it for me too.
Most helpful comment
Make sure you have this in your csproj file: