Results 1 to 7 of 7

Thread: Is there a way to do this?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    167

    Is there a way to do this?

    How can I set up a class such that its the main one and so that it is the first to be run by the program?

  2. #2
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Is there a way to do this?

    Create a method called 'Main' and change the startup object option in the project settings.

    If by class you mean a form, then you don't need to create a method called Main, you just need to change the startup object to that form.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    167

    Re: Is there a way to do this?

    Thanks. Ill try that.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    167

    Re: Is there a way to do this?

    Hi. Im creating a WPF project and would like to make the Main method or my Main class to run o startup. But I dont get the option in project properties.

  5. #5

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    167

    Re: Is there a way to do this?

    Sorry. I didnt realise itd make a difference.

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Is there a way to do this?

    Quote Originally Posted by quddusaliquddus View Post
    Hi. Im creating a WPF project and would like to make the Main method or my Main class to run o startup. But I dont get the option in project properties.
    Just as in WinForms, if you want to create your own Main method as the application entry point then you have to disable the Application Framework in the project properties. If you do that then the Startup URI becomes Startup Object and automatically switches from a Window to Sub Main.

    That said, in most cases you shouldn't be doing this. This is another case of where you should be explaining what you're actually trying to achieve and not how you're trying to achieve it. Why exactly do you want to do what you're suggesting? Quite possibly you should simply be handling the Startup event of the application.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width