Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2022 'Forms' does not exist in the namespace system.windows

According to other answers, I try to add project reference. I open the reference manager to find System.Windows.Forms and add it, but the project reference shows "No items found". So how can I add the reference? enter image description here

enter image description here

like image 913
LukeSU Avatar asked Nov 30 '25 19:11

LukeSU


1 Answers

As Jimi's comment suggests, you cannot directly reference System.Windows.Forms.dll because it's part of the runtime. Instead, add the following to your project file: <UseWindowsForms>true</UseWindowsForms> and make sure the target framework is set as <TargetFramework>net6.0-windows</TargetFramework> (and not only net6.0), because Windows Forms is only supported on Windows.

like image 98
PMF Avatar answered Dec 02 '25 08:12

PMF