How to reference System.Windows.Forms in .NET Core 3.0 for WPF apps?

And this is how to reference System.Windows.Forms in .NET 5.0 for WPF apps and WindowsForms

<PropertyGroup>
   <TargetFramework>net5.0-windows</TargetFramework>
   <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
   <UseWPF>true</UseWPF>
   <UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>

Looks like it already exists: https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.folderbrowserdialog?view=netcore-3.0

For other porting issues, you might want to use the Windows Compatibility Pack which is used to help port apps to .NET Core

There also might be some more information out there related to WPF and this issue, since it's been around for awhile. This might be helpful Select folder dialog WPF, and updated for .NET Core.

Good luck with your upgrade!


You need to add to csproj an additional switch:

<UseWindowsForms>true</UseWindowsForms>

Add it below UseWpf. Then try rebuild. After this, you should be able to use Forms namespace.