@@ -32,6 +32,7 @@ public partial class App : IDisposable, ISingleInstanceApp
3232 private const string Unique = "Flow.Launcher_Unique_Application_Mutex" ;
3333 private static bool _disposed ;
3434 private readonly Settings _settings ;
35+ private readonly IHost _host ;
3536
3637 public App ( )
3738 {
@@ -68,22 +69,37 @@ public App()
6869 WriteToLogFile ( 5 ) ;
6970
7071 // Configure the dependency injection container
71- var host = Host . CreateDefaultBuilder ( )
72- . UseContentRoot ( AppContext . BaseDirectory )
73- . ConfigureServices ( services => services
74- . AddSingleton ( _ => _settings )
75- . AddSingleton ( sp => new Updater ( sp . GetRequiredService < IPublicAPI > ( ) , Launcher . Properties . Settings . Default . GithubRepo ) )
76- . AddSingleton < Portable > ( )
77- . AddSingleton < SettingWindowViewModel > ( )
78- . AddSingleton < IAlphabet , PinyinAlphabet > ( )
79- . AddSingleton < StringMatcher > ( )
80- . AddSingleton < Internationalization > ( )
81- . AddSingleton < IPublicAPI , PublicAPIInstance > ( )
82- . AddSingleton < MainViewModel > ( )
83- . AddSingleton < Theme > ( )
84- ) . Build ( ) ;
72+ try
73+ {
74+ WriteToLogFile ( $ "AppContext.BaseDirectory: { AppContext . BaseDirectory } ") ;
75+ _host = Host . CreateDefaultBuilder ( )
76+ . UseContentRoot ( AppContext . BaseDirectory )
77+ . ConfigureServices ( services => services
78+ . AddSingleton ( _ => _settings )
79+ . AddSingleton ( sp => new Updater ( sp . GetRequiredService < IPublicAPI > ( ) , Launcher . Properties . Settings . Default . GithubRepo ) )
80+ . AddSingleton < Portable > ( )
81+ . AddSingleton < SettingWindowViewModel > ( )
82+ . AddSingleton < IAlphabet , PinyinAlphabet > ( )
83+ . AddSingleton < StringMatcher > ( )
84+ . AddSingleton < Internationalization > ( )
85+ . AddSingleton < IPublicAPI , PublicAPIInstance > ( )
86+ . AddSingleton < MainViewModel > ( )
87+ . AddSingleton < Theme > ( )
88+ ) . Build ( ) ;
89+ }
90+ catch ( Exception ex )
91+ {
92+ WriteToLogFile ( ex . Message ) ;
93+ }
8594 WriteToLogFile ( 6 ) ;
86- Ioc . Default . ConfigureServices ( host . Services ) ;
95+ try
96+ {
97+ Ioc . Default . ConfigureServices ( _host . Services ) ;
98+ }
99+ catch ( Exception ex )
100+ {
101+ WriteToLogFile ( ex . Message ) ;
102+ }
87103 WriteToLogFile ( 7 ) ;
88104
89105 // Initialize the public API and Settings first
0 commit comments