@@ -35,31 +35,52 @@ public partial class App : IDisposable, ISingleInstanceApp
3535 public App ( )
3636 {
3737 // Initialize settings
38- var storage = new FlowLauncherJsonStorage < Settings > ( ) ;
39- _settings = storage . Load ( ) ;
40- _settings . SetStorage ( storage ) ;
41- _settings . WMPInstalled = WindowsMediaPlayerHelper . IsWindowsMediaPlayerInstalled ( ) ;
38+ try
39+ {
40+ var storage = new FlowLauncherJsonStorage < Settings > ( ) ;
41+ _settings = storage . Load ( ) ;
42+ _settings . SetStorage ( storage ) ;
43+ _settings . WMPInstalled = WindowsMediaPlayerHelper . IsWindowsMediaPlayerInstalled ( ) ;
44+ }
45+ catch ( Exception e )
46+ {
47+ MessageBoxEx . Show ( $ "Cannot load setting storage: { e } ") ;
48+ }
4249
4350 // Configure the dependency injection container
44- var host = Host . CreateDefaultBuilder ( )
45- . UseContentRoot ( AppContext . BaseDirectory )
46- . ConfigureServices ( services => services
47- . AddSingleton ( _ => _settings )
48- . AddSingleton ( sp => new Updater ( sp . GetRequiredService < IPublicAPI > ( ) , Launcher . Properties . Settings . Default . GithubRepo ) )
49- . AddSingleton < Portable > ( )
50- . AddSingleton < SettingWindowViewModel > ( )
51- . AddSingleton < IAlphabet , PinyinAlphabet > ( )
52- . AddSingleton < StringMatcher > ( )
53- . AddSingleton < Internationalization > ( )
54- . AddSingleton < IPublicAPI , PublicAPIInstance > ( )
55- . AddSingleton < MainViewModel > ( )
56- . AddSingleton < Theme > ( )
57- ) . Build ( ) ;
58- Ioc . Default . ConfigureServices ( host . Services ) ;
51+ try
52+ {
53+ var host = Host . CreateDefaultBuilder ( )
54+ . UseContentRoot ( AppContext . BaseDirectory )
55+ . ConfigureServices ( services => services
56+ . AddSingleton ( _ => _settings )
57+ . AddSingleton ( sp => new Updater ( sp . GetRequiredService < IPublicAPI > ( ) , Launcher . Properties . Settings . Default . GithubRepo ) )
58+ . AddSingleton < Portable > ( )
59+ . AddSingleton < SettingWindowViewModel > ( )
60+ . AddSingleton < IAlphabet , PinyinAlphabet > ( )
61+ . AddSingleton < StringMatcher > ( )
62+ . AddSingleton < Internationalization > ( )
63+ . AddSingleton < IPublicAPI , PublicAPIInstance > ( )
64+ . AddSingleton < MainViewModel > ( )
65+ . AddSingleton < Theme > ( )
66+ ) . Build ( ) ;
67+ Ioc . Default . ConfigureServices ( host . Services ) ;
68+ }
69+ catch ( Exception e )
70+ {
71+ MessageBoxEx . Show ( $ "Cannot configure dependency injection container: { e } ") ;
72+ }
5973
6074 // Initialize the public API and Settings first
61- API = Ioc . Default . GetRequiredService < IPublicAPI > ( ) ;
62- _settings . Initialize ( ) ;
75+ try
76+ {
77+ API = Ioc . Default . GetRequiredService < IPublicAPI > ( ) ;
78+ _settings . Initialize ( ) ;
79+ }
80+ catch ( Exception e )
81+ {
82+ MessageBoxEx . Show ( $ "Cannot initialize public API and settings: { e } ") ;
83+ }
6384 }
6485
6586 [ STAThread ]
0 commit comments