How WPF is launched using App.xaml / cs and MainWindow.xaml / cs

Suppose we start with a new default WPF project using App.xaml / cs, MainWindow.xaml / cs What order the application executes these codes. Parse App.xaml β†’ launch App.xaml.cs β†’ parse MainWindow.xaml β†’ launch MainWindow.xaml.cs? and what about executing Resource.Designer.cs and Settings.Designer.cs in properties?

+4
source share
2 answers

Each dotnet application (PE files) starts with an entry point, which is usually "Main", but in wpf you cannot see this because the studio is hiding it from the user, as this is rather dirty code. you will know the thread of execution as soon as you find the Main method. To do this, take a look at the following image enter image description here

+4
source

As the Int3 user says, the Main method is in App.g.cs and looks like this

public static void Main() { YourAppNamespace.App app = new YourAppNamespace.App(); app.InitializeComponent(); app.Run(); } 

This means that you will create the application constructor first.

+2
source

All Articles