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?
 
Refael AckermannConnect With a Mentor Commented:
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
 
Unimatrix_001Author Commented:
Thank you. :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.