'How can I add System.Windows.Forms to WPF application when adding via reference/Depenency doesn't work?
Following every guide everywhere:
- Step 1:
- Step 2: it works! Huzzah! Except that it doesn't. Instead I get yellow triangles:
This project is tiny for now because I only just started. The guides about yellow triangles talk about conflicts which can't be the case here. I have next to nothing imported or used yet:
Solution 1:[1]
Apparently this is due to using .Net Core and Microsoft couldn't anticipate that people would want to use forms in the new normal...
I found this: How to use System.Windows.Forms in .NET Core class library
This is what worked:
- Removed reference/dependancy entirely
- Right-click project, Unload
- Right-click project, Edit project file
- Add the following:
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
- Reload project file
- Add "using system.windows.forms" to the top.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | not_a_generic_user |



