public ApplicationSettingsService(AppSettingsRepository appSettingsRepository) { _appSettingsRepository = appSettingsRepository; try { _applicationSettings = _appSettingsRepository.LoadSettings(); if (_applicationSettings == null) { _applicationSettings = AppSettingsRepository.GetDefaultApplicationSettings(); _appSettingsRepository.SaveSettings(_applicationSettings); } } catch (Exception ex) { Log.Error(ex, "Fatal error encountered when accessing the registry settings"); throw new IOException("Application Settings could not be loaded and could not be set to default and saved"); } _appSettingsRepository.LoadSettingsCompleted += _appSettingsFileRepository_LoadSettingsCompleted; }