Reputation: 1
I'm trying to write code for forms without using MS Designer.
When I compile, I'm consistently getting the same errors:
The type System.ComponentModel.* is defined in an assembly that is not referenced.
This will appear for IComponent, ISynchronizeInvoke, and Component. I think I have referenced it.
I've tried removing the reference and re-applying it, and switching to earlier versions of .net. It has to be something in my environment, but I cannot find it.
using System;
using System.ComponentModel;
using System.Windows.Forms;
public class EmptyForm : System.Windows.Forms.Form
{
public EmptyForm()
{
}
public static int Main()
{
Application.Run(new EmptyForm());
return 0;
}
}
Upvotes: 0
Views: 307
Reputation: 4399
To add a reference, just right click on References and choose Add Reference. There you can add the relevant references.
You have the using
directive, but you are not referencing the assembly.
Upvotes: 3
Reputation: 888067
As the error clearly states, you need to add a reference to System.
Upvotes: 5