diff --git a/DiscordChatExporter.Gui/App.axaml.cs b/DiscordChatExporter.Gui/App.axaml.cs index b4f624d3..6dfdc584 100644 --- a/DiscordChatExporter.Gui/App.axaml.cs +++ b/DiscordChatExporter.Gui/App.axaml.cs @@ -97,9 +97,10 @@ public class App : Application, IDisposable { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - desktop.MainWindow = _services - .GetRequiredService() - .TryBindWindow(_services.GetRequiredService().GetMainViewModel()); + var viewManager = _services.GetRequiredService(); + var viewModelManager = _services.GetRequiredService(); + + desktop.MainWindow = viewManager.TryBindWindow(viewModelManager.GetMainViewModel()); // Although `App.Dispose()` is invoked from `Program.Main(...)`, on some platforms // it may be called too late in the shutdown lifecycle. Attach an exit