You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have read the WPF Integration docs and they tell me to do it like this (compact version shown):
static class Program
{
[STAThread]
static void Main()
{
var container = Bootstrap();
var app = new App();
var mainWindow = container.GetInstance<MainWindow>();
app.Run(mainWindow);
}
}
On the other hand, a StackOverflow guruThe Man recommends to override the App.OnStartup event:
The appropriate entry point depends on the framework:
In console applications it's the Main method
In ASP.NET MVC applications it's global.asax and a custom IControllerFactory
In WPF applications it's the Application.OnStartup method
In WCF it's a custom ServiceHostFactory
etc.
(you can read more about framework-specific Composition Roots in chapter 7 of my book.)
I am, thus, using Simple Injector like this, with the same visible behaviour, and - IMO - a lot less invasiveness:
// after removing StartupUri from App.xaml...
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var bootstrapper = new BootStrapper();
MainWindow = bootstrapper.GetMainWindow();
MainWindow.Show();
}
}
Besides some minor variations, the whole point is the idea of not bypassing the normal WPF App instantiation, but instead just to override OnStartup event.
What do you think of changing the documentation to reflect this?
The text was updated successfully, but these errors were encountered:
I have read the WPF Integration docs and they tell me to do it like this (compact version shown):
On the other hand,
a StackOverflow guruThe Man recommends to override theApp.OnStartup
event:I am, thus, using Simple Injector like this, with the same visible behaviour, and - IMO - a lot less invasiveness:
Besides some minor variations, the whole point is the idea of not bypassing the normal WPF App instantiation, but instead just to override
OnStartup
event.What do you think of changing the documentation to reflect this?
The text was updated successfully, but these errors were encountered: