Added logic to delete "bad" user.config files.

This commit is contained in:
Rich 2013-01-07 19:47:08 +00:00
parent 45970cffbb
commit 9982b90359

View File

@ -112,11 +112,32 @@ namespace VEPROMS
#endregion
public frmVEPROMS()
{
if (Properties.Settings.Default.UpdateSettings)
// The following Try/Catch was added to protect against a problem seen by Kathy and Michelle
// on January 1, 2013. Michelle's user.config file was empty and PROMS would not run.
// This logic will delete a "Bad" config file to attempt to eliminate the problem, and
// instructs the user to try again.
try
{
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.UpdateSettings = false;
Properties.Settings.Default.Save();
if (Properties.Settings.Default.UpdateSettings)
{
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.UpdateSettings = false;
Properties.Settings.Default.Save();
}
}
catch (Exception ex)
{
_MyLog.Error(ex.GetType().Name + " - " + ex.InnerException, ex);
if (ex.Message.StartsWith("Configuration system failed to initialize"))
{
string filename = ex.InnerException.Message;
filename = filename.Substring(filename.IndexOf("(") + 1);
filename = filename.Substring(0, filename.IndexOf("user.config") + 11);
FileInfo myfile = new FileInfo(filename);
myfile.Delete();
MessageBox.Show("Config file was corrupt, it has been deleted.\r\nTry Again", "Corrupt config file", MessageBoxButtons.OK, MessageBoxIcon.Error);
System.Diagnostics.Process.GetCurrentProcess().Kill();
}
}
// cleanup from previous run:
Volian.Base.Library.TmpFile.RemoveAllTmps();