A Solution's Start Up Object

B

Bob Day

Usinb VS2003, VB.net, MSDE...

Is there any advantage to these three alternatives as the start up object in
the solution property pages for a winform solution on a stand alone desktop?
1 - Sub Main in module that starts WinForm_Main
2 - Shared Sub Main in WinForm_Main itself
3 - Using WinForm_Main as start up object with no Sub Main anywhere

I have seen sample programs use all 3 of these, and I am not sure what the
best practice is. It seems to be that a Sub Main (or Shared Sub Main with
form load empty) is the best approach, since you could try/catch there,
essentially catching all uncaught exceptions (I am not sure where you would
do that if WinForm_Main were the start up object).

I don't see any difference in Sub Main being in the WinForm_Main or a
seperate module.

What are the pros and cons, if any? Any URL to such an info would be
appreciated.

Thanks!
Bob Day
 
P

Patrick Steele [MVP]

Is there any advantage to these three alternatives as the start up object in
the solution property pages for a winform solution on a stand alone desktop?
1 - Sub Main in module that starts WinForm_Main
2 - Shared Sub Main in WinForm_Main itself
3 - Using WinForm_Main as start up object with no Sub Main anywhere

I can't really think of one advantage over the other. I guess it
depends on the situation.
 
H

Herfried K. Wagner [MVP]

* "Bob Day said:
Usinb VS2003, VB.net, MSDE...

Is there any advantage to these three alternatives as the start up object in
the solution property pages for a winform solution on a stand alone desktop?
1 - Sub Main in module that starts WinForm_Main
2 - Shared Sub Main in WinForm_Main itself
3 - Using WinForm_Main as start up object with no Sub Main anywhere

It's just a matter of personal preference. I always write a shared 'Sub
Main' inside a class called 'AppMain', but sometimes that's not even
necessary if there is nothing to process prior to showing the first form.
 
P

Peter Huang

Hi Bob,

Thanks for posting in the community.
1 - Sub Main in module that starts WinForm_Main
2 - Shared Sub Main in WinForm_Main itself
3 - Using WinForm_Main as start up object with no Sub Main anywhere

I agree with Patrick and Herfried's suggestion, the three methods are used
according to the suituation.
If you wants to do some initialization stuff before the run the winform,
you may need to use the method 1 or 2, otherwise you can use the method 3
directly.

If you have any concern on this issue,please post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
C

Cor

Hi Peter,

There are now 3 questions in top of the newsgroup
microsoft.public.dotnet.general from which I thought you know the answer.

It is about installing VS.net

Cor
 

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

Top