Starting a C# app without a form

P

Paul BJ

I have developed a mini-app that does some routine maintenance tasks on
my Outlook 2003 files.

For the dev process, I ran a form with just a GO button on it but now
that the app is ready for testing, I want to run it without any user
interface.

Up until now, I have started it with:
Application.Run(new Form1());

but now I don't want a form to load; I have searched the doc but I
cannot find out how to start the app without loading a form.

What I really want to do is to instantiate an object of a type from one
of my classes and then execute one of its methods: something like:

ClassOutlook objOL = new ClassOutlook();
objOL.SaveOutlookAttachments();

anyone out there know how this can be done?

Cheers

Paul BJ
 
A

Ajay Kalra

If you use the following:

ClassOutlook objOL = new ClassOutlook();
objOL.SaveOutlookAttachments()­;

instead of Application.Run(new Form1()), your app will exit as soon as
SaveOutlookAttachments is called. Is that what you want?
 
P

Paul BJ

Ajay said:
If you use the following:

ClassOutlook objOL = new ClassOutlook();
objOL.SaveOutlookAttachments()­;

instead of Application.Run(new Form1()), your app will exit as soon as
SaveOutlookAttachments is called. Is that what you want?
I don't understand....do I still call

Application.Run() ?

I want objOL.SaveOutlookAttachments() to run ...then it can exit...is that what you meant?

What I want is
ClassOutlook objOL = new ClassOutlook();
objOL.SaveOutlookAttachments()­

to run when the app is started...if there is no other code after
objOL.SaveOutlookAttachments() then yes it will exit.
Cheers

Paul BJ
­
 
V

VJ

Paul.. are you looking to do like a Service or Console application.. a few
options.. These type of projects will not have a UI interface by default &
you can execute code & exit application without showing UI.

VJ
 
A

Ajay Kalra

Paul said:
I want objOL.SaveOutlookAttachments() to run ...then it can exit...is
that what you meant?

Then simply have a Console application. It will execute your statements and
exit as you want.
 
J

James Curran

Then simply have a Console application. It will execute your statements and
exit as you want.

Not exactly. He has a Windows application which never creates a window,
which is not a Console app (because it also does not create a console
window)
 
A

Ajay Kalra

James said:
Not exactly. He has a Windows application which never creates a
window, which is not a Console app (because it also does not create a
console window)

What I suggested was to have a console app as it appears OP does not really
need a Form.
 

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

Similar Threads


Top