?
Solved

Application.run - not triggering App_Startup

Posted on 2008-11-09
2
Medium Priority
?
198 Views
Last Modified: 2013-12-17
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

0
Comment
Question by:Unimatrix_001
2 Comments
 
LVL 7

Accepted Solution

by:
moseack earned 2000 total points
ID: 22915774
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
 
LVL 3

Author Closing Comment

by:Unimatrix_001
ID: 31514808
Thank you. :-)
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month16 days, 5 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question