protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); exportProvider = initializeMEFTask.GetAwaiter().GetResult(); var cultureService = exportProvider.GetExportedValue <CultureService>(); cultureService.Initialize(args); // Make sure IDpiService gets created before any MetroWindows exportProvider.GetExportedValue <IDpiService>(); // It's needed very early, and an IAutoLoaded can't be used (it gets called too late for the first 64x64 image request) DsImageConverter.imageService = exportProvider.GetExportedValue <IImageService>(); appWindow = exportProvider.GetExportedValue <AppWindow>(); extensionService = exportProvider.GetExportedValue <ExtensionService>(); dsLoaderService = exportProvider.GetExportedValue <IDsLoaderService>(); extensionService.LoadedExtensions = loadedExtensions; appWindow.CommandLineArgs = args; var win = appWindow.InitializeMainWindow(); appWindow.MainWindow.SourceInitialized += MainWindow_SourceInitialized; dsLoaderService.OnAppLoaded += DsLoaderService_OnAppLoaded; dsLoaderService.Initialize(appWindow, win, args); extensionService.LoadExtensions(Resources.MergedDictionaries); win.Show(); }