|
-
Mar 28th, 2010, 04:50 PM
#1
Thread Starter
Addicted Member
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?
-
Mar 28th, 2010, 04:52 PM
#2
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.
-
Mar 28th, 2010, 05:02 PM
#3
Thread Starter
Addicted Member
Re: Is there a way to do this?
-
Mar 28th, 2010, 05:07 PM
#4
Thread Starter
Addicted Member
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.
-
Mar 28th, 2010, 05:11 PM
#5
Re: Is there a way to do this?
Then you should have posted in the WPF forum instead. I never used WPF so I can't answer your question.
-
Mar 28th, 2010, 05:13 PM
#6
Thread Starter
Addicted Member
Re: Is there a way to do this?
Sorry. I didnt realise itd make a difference.
-
Mar 28th, 2010, 08:16 PM
#7
Re: Is there a way to do this?
 Originally Posted by quddusaliquddus
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|