0

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.

4

2 回答 2

5

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

于 2013-05-17T20:35:29.967 回答
3

要添加引用,只需右键单击References并选择Add Reference。在那里您可以添加相关参考。

你有using指令,但你没有引用程序集。

于 2013-05-17T20:36:29.897 回答