LavaGang / MelonLoader.Installer

The Official Dedicated Installer for MelonLoader
https://github.com/lavagang/melonloader
Apache License 2.0
50 stars 24 forks source link

[Bug] Fatal Exception on non-existent LastSelectedGamePath #14

Closed JustArion closed 1 week ago

JustArion commented 1 year ago

Stacktrace:

Application: MelonLoader.Installer.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.DirectoryNotFoundException
   at System.Windows.Forms.Control.MarshaledInvoke(System.Windows.Forms.Control, System.Delegate, System.Object[], Boolean)
   at System.Windows.Forms.Control.Invoke(System.Delegate, System.Object[])
   at System.Windows.Forms.Control.Invoke(System.Delegate)
   at MelonLoader.ThreadHandler.RefreshReleases()
   at MelonLoader.ThreadHandler.GetReleases()
   at MelonLoader.ThreadHandler.CheckForInstallerUpdate()
   at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart()

The exception is likely thrown at MainForm.cs#L98 due to ThreadHandler.cs#L180

Solutions to this could be checking either File.Exists(Config.LastSelectedGamePath) after the string.IsNullOrEmpty check or a Directory.Exists(Path.GetDirectoryName(Config.LastSelectedGamePath))

The File.Exists being the likely best option since the game path includes the .exe.