Configuration system failed to initialize

Time:2021-1-20

Recently, users reported that some computer startup programs crashed, and also demonstrated a strange problem

“Copy the software back to another directory and it will work.”.Also said that a period of time and can not run, you need to change the location.

’Because there was no global exception set at that time, it could only be analyzed with the help of the system operation log. If the system log record is incomplete, it means that an exception occurred and the program failed.

Simply add global exception capture. 

public class ExceptionHelper
    {
        public static void InitException()
        {
            Application.Current.DispatcherUnhandledException += Application_DispatcherUnhandledException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
        }

        private static void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            LogManager.WriteException(e.Exception);
            e.Handled = true;
        }

        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var exception = e.ExceptionObject as Exception;
            if (exception != null)
            {                
                LogManager.WriteException(exception);
            }
        }
    }

After adding the log details, see the promptConfiguration system failed to initializeError message. Then with the help of search, find an article.

There are two reasons

1、 In the config fileThe location order of or content format error.

2、 When the user scope configuration item is included, user.config The file is damaged.

 

Combined with their own procedures do use TaoThis node,It is used to save the position of the program on the screen. The node is on the top and the format of the detected content is normal.

That leaves the second possibility. Find the location: C: users\Administrator\AppData\Local\SuspendWpfApp,Just delete the files inside

 Administrator:User nameSuspendWpfApp:Software name.

In order to completely solve this problem, no longer use Properties.Settings.Default To save information, save the last information with a file.

Once there is a problem with usersettings, the information that depends on the Appsettings node in the software will not be available.

 

Recommended Today

Format date by type

Format date by type About more daily use of public class operation method, you can pay attention to the next small website http://www.feiaci.com/#/self/… Format date by type /** *Format date by type *@ param {*} date specific date variable *@ param {string} datetype needs return types, including (‘yyyy MM DD ‘,’yyyy MM DD’, * ‘ […]