I have just started working on c#, and was fiddling with some code sample that I got from some forum.
This code is using a namespace using system.windows.forms
for which I am getting an error:
Forms does not exist in the namespace system.windows.
Also I am getting some error related to undefined functions for senddown
& sendup
which I believe to be in the Forms
name space.
I am using visual studio 10 (with .net frame work 4.0). Any idea how to fix this error?
Forms Namespace. Contains classes for creating Windows-based applications that take full advantage of the rich user interface features available in the Microsoft Windows operating system.
Windows. Forms as a reference in your project. Right-click on 'References' , select 'Add Reference' and look under Assemblies in the dialogue. If you created your project as a Windows Forms project, that reference should have been added for you automatically.
Expand the project in Solution Tree, Right-Click on References
, Add Reference
, Select System.Windows.Forms
on Framework
tab.
You need to add reference to some non-default assemblies sometimes.
From comments: for people looking for VS 2019+: Now adding project references is Right-Click on Dependencies
in Solution Explorer
.
For people looking for VS Code: How do I add assembly references in Visual Studio Code
In case someone runs into this error when trying to reference Windows Forms components in a .NET Core 3+ WPF app (which is actually not uncommon), the solution is to go into the .csproj
file (double click it in VS2019) and add it to the property group node containing the target frameworks. Like this:
<PropertyGroup> <TargetFramework>netcoreapp3.0</TargetFramework> <UseWPF>true</UseWPF> <UseWindowsForms>true</UseWindowsForms> </PropertyGroup>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With