A Solution's Start Up Object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob Day

    A Solution's Start Up Object

    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



  • Patrick Steele [MVP]

    #2
    Re: A Solution's Start Up Object

    In article <u01WIyb5DHA.48 8@TK2MSFTNGP12. phx.gbl>, BobDay@TouchTal k.net
    says...[color=blue]
    > 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[/color]

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

    --
    Patrick Steele
    Microsoft .NET MVP

    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: A Solution's Start Up Object

      * "Bob Day" <BobDay@TouchTa lk.net> scripsit:[color=blue]
      > 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[/color]

      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.

      --
      Herfried K. Wagner [MVP]
      <http://www.mvps.org/dotnet>

      Comment

      • Peter Huang

        #4
        RE: A Solution's Start Up Object

        Hi Bob,

        Thanks for posting in the community.
        [color=blue]
        > 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[/color]

        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.

        Comment

        • Cor

          #5
          OT: Installing VS net

          Hi Peter,

          There are now 3 questions in top of the newsgroup
          microsoft.publi c.dotnet.genera l from which I thought you know the answer.

          It is about installing VS.net

          Cor


          Comment

          Working...