chocolatey / ChocolateyGUI

A delicious GUI for Chocolatey
https://docs.chocolatey.org/en-us/chocolatey-gui/
Apache License 2.0
1.62k stars 250 forks source link

ChocolateyGUI doesn't start if user.config under %AppData% is corrupt. #864

Open ezxpro opened 3 years ago

ezxpro commented 3 years ago

Here this bug is 100% reproducible. The userconfig file I have under %AppData%\Local\Chocolatey\ChocolateyGui.exe_StrongName_qgbusv5dfgkxx33orw4dqzgj3f5c3jne\0.18.1.0 somehow got corrupt (attached below) corrupt.user.zip

and read something like image

Although the cli command choco worked just fine, ChocolateyGUI would crash while initializing without showing any errors. Upon deleting the bad file it worked just fine.

Whatever is it that is wrong with this file, chocolateyGUI should be aware that the file syntax is bad and do something about it.

MohandL3G commented 2 years ago

Thank you so much, I've had this issue like more than 3 days, tried to reinstall, uninstall then install again, nothing worked.

I navigated to this dir, and found the user.config is corrupted, and renamed it to ""user.config.bak", now ChocolateyGUI is working fine, please fix this.

corbob commented 2 years ago

I can confirm this issue occurs when the xml is modified to have an invalid element (or invalid xml). There is an error message that appears, but it is ever so brief. I was barely able to capture it through the disappearing chocolatey logo: image

Effectively this error is saying that it doesn't know what the element settin is (I removed the g from setting as a test).

The pertinent entries from the log:

2021-08-09 13:38:30.401 -07:00 [Fatal] Failed to start application.
System.Configuration.ConfigurationErrorsException: Unrecognized element 'settin'. (C:\Users\CoryKnox\AppData\Local\Chocolatey\ChocolateyGui.exe_StrongName_qgbusv5dfgkxx33orw4dqzgj3f5c3jne\0.18.1.0\user.config line 10)
   at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
   at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
   at System.Configuration.ConfigurationManager.GetSection(String sectionName)
   at System.Configuration.ClientSettingsStore.ReadSettings(String sectionName, Boolean isUserScoped)
   at System.Configuration.LocalFileSettingsProvider.GetPropertyValues(SettingsContext context, SettingsPropertyCollection properties)
   at System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider provider)
   at System.Configuration.SettingsBase.GetPropertyValueByName(String propertyName)
   at System.Configuration.SettingsBase.get_Item(String propertyName)
   at System.Configuration.ApplicationSettingsBase.GetPropertyValue(String propertyName)
   at System.Configuration.ApplicationSettingsBase.get_Item(String propertyName)
   at MahApps.Metro.Controls.WindowApplicationSettings.get_Placement() in /_/src/MahApps.Metro/Controls/WindowSettings.cs:line 54
   at MahApps.Metro.Behaviors.WindowsSettingBehavior.LoadWindowState() in /_/src/MahApps.Metro/Behaviors/WindowsSettingBehavior.cs:line 139
   at MahApps.Metro.Behaviors.WindowsSettingBehavior.AssociatedObject_SourceInitialized(Object sender, EventArgs e) in /_/src/MahApps.Metro/Behaviors/WindowsSettingBehavior.cs:line 37
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.Windows.Window.OnSourceInitialized(EventArgs e)
   at System.Windows.Window.CreateSourceWindow(Boolean duringShow)
   at System.Windows.Window.ShowHelper(Object booleanBox)
   at ChocolateyGui.Common.Windows.Bootstrapper.<OnStartup>d__43.MoveNext() in C:\github_local\organisations\chocolatey\ChocolateyGUI\Source\ChocolateyGui.Common.Windows\Bootstrapper.cs:line 134
corbob commented 2 years ago

I've done some investigation and some stepping through the debugger. I can step all the way until Line 106 in App.xaml.cs at which point the debugger just runs off until it reports an unhandled exception. Following that rabbit hole, I've gotten to the point of determining that it's coming from MahApps.Metro, and eventually reports back to Bootstrapper.cs line 136 where we display a MessageBox which appears for a split second (even when debugging) before disappearing. Ideally if the error message could actually stick around this error would be easier for the user to handle.