The type or namespace name "Application" could not be found

  • Thread starter Thread starter Le, Thanh-Nhan
  • Start date Start date
L

Le, Thanh-Nhan

Hi,
I am a beginner in .NET.
I am creating a new project. At begin I created this project with a form,
then a class."start"
I want to use class "start" as start point for this program. In this class I
wrote:
[STAThread]

static void Main()

{

Application.Run(new start());

}

But I can not build, compile the project, the error is:


The type or namespace name "Application" could not be found

What can I do?

Thanks
Nhan
 
Le said:
I am a beginner in .NET.
I am creating a new project. At begin I created this project with a form,
then a class."start"
I want to use class "start" as start point for this program. In this class I
wrote:
[STAThread]

static void Main()

{

Application.Run(new start());

}

But I can not build, compile the project, the error is:


The type or namespace name "Application" could not be found

What can I do?

Make sure you have "using System.Windows.Forms;" in your list of using
directives.
 
Le said:
The type or namespace name "Application" could not be found

Application is a member of System.Windows.Forms namespace.
So You need to add
"using System.Windows.Forms;" line at the beginning
or change Your line to
"System.Windows.Forms.Application.Run(new start());"

Additionally You may need to add "System.Windows.Forms.dll" to Your project
references.

RGDS PSG
 
I have now the line:
using System.Windows.Forms;

then I have the compile error: "The best overloaded method match for
"System.Windows.Forms.Application.Run(System.Windows.Forms)" has some
invalid
argument"

OK, I can understand, the object parameter must be a form object, my "start"
class is any form, is only a normal class.
How can I do? Is it possible, to use a normal class (as in java, or VB6) as
start point for a program?

Nhan

Jon Skeet said:
Le said:
I am a beginner in .NET.
I am creating a new project. At begin I created this project with a form,
then a class."start"
I want to use class "start" as start point for this program. In this class I
wrote:
[STAThread]

static void Main()

{

Application.Run(new start());

}

But I can not build, compile the project, the error is:


The type or namespace name "Application" could not be found

What can I do?

Make sure you have "using System.Windows.Forms;" in your list of using
directives.
 
Thanks
please see my posting to Jon Skeet
Nhan


psg said:
Application is a member of System.Windows.Forms namespace.
So You need to add
"using System.Windows.Forms;" line at the beginning
or change Your line to
"System.Windows.Forms.Application.Run(new start());"

Additionally You may need to add "System.Windows.Forms.dll" to Your project
references.

RGDS PSG
 
Le said:
OK, I can understand, the object parameter must be a form object

Yes one of options is Form.
my "start" class is any form, is only a normal class.
How can I do? Is it possible, to use a normal class (as in java, or VB6)
as
start point for a program?

In a Main function You can Initialize Your "start" class ("start myStart =
new start();") and run its methods or if start() is only a method/function
of current class You can run it through e.g. "start();"

RGDS PSG
 
OK, thanks.

in Main function (static void Main() ) I call: start app = new start();
then in contructor of class start, I do everything.
 
Back
Top