Application.run - not triggering App_Startup

Hi,

I'm using VS08 and I'm trying to create my own WPF application. I've moved the Main method from the generic file to my own, and am trying to run the attached code, however I'm not getting a messagebox, and the program is not shutting down. The program is starting up as the process is visible in process manager.

Thanks,
Uni
namespace MyApplication
{
    public partial class App : Application
    {
        public static void Main()
        {
            new App().Run();
        }
 
        void App_Startup(object sender, StartupEventArgs e)
        {
            MessageBox.Show("Hello!");
            Shutdown();
        }
    }
}

Open in new window

LVL 3
Unimatrix_001Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Refael AckermannCommented:
If you moved this code to a different file (than the XAML code behind) you lose the "AutoEventWireup", so you'll need to attach your event handler manualy (BTW: in this case you can remove the "partial" keyword).

        public static void Main()
        {
            var app = new App();
            app.Statup += App_Startup;
            app.Run();
        }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Unimatrix_001Author Commented:
Thank you. :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.