Starting a windows application from outside the form

  • Thread starter Thread starter Jesse
  • Start date Start date
J

Jesse

Hi,

Can anyone suggest how to go about running a windows application from
outside the starting form. ie. making a call to the initial form and then
showing it. I have tried this using a separate class file with static void
Main()
{
MainForm mf = new MainForm();
mf.Show();
}

But as soon as the form shows the application ends. As you can tell i am an
absolute novice so any help would be appreciated.

Thanks,
Jesse
 
You need to keep pumping the Window messages to the window. You can do that
by

Main()
{
MainForm mf = new MainForm();
Application.Run(mf);
}

-vJ
 
Hi, thanks for the reply.

When i do that i get an error:

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

what does this mean?
 
Try System.Windows.Forms.Application or add "using System.Windows.Forms" to
the top of the file.

-vJ
 
Wooho. That works. Thanks.


Vijaye Raji said:
Try System.Windows.Forms.Application or add "using System.Windows.Forms" to
the top of the file.

-vJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top