user1764241
user1764241

Reputation: 1

C# (Visual Studio 2010) not finding an included reference

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;
    }
}

Screen shot of my Visual Studio.

Upvotes: 0

Views: 307

Answers (2)

hattenn
hattenn

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

SLaks
SLaks

Reputation: 888067

As the error clearly states, you need to add a reference to System.

Upvotes: 5

Related Questions