diff --git a/BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs b/BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs index e6d1684bce..8e164865d1 100644 --- a/BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs +++ b/BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs @@ -99,10 +99,12 @@ namespace BizHawk.Client.EmuHawk Console.WriteLine(v); } } - catch + catch (Exception ex) { if (!bootstrap) - MessageBox.Show("Couldn't load the selected Libretro core for analysis. It won't be available."); + { + MessageBox.Show("Couldn't load the selected Libretro core for analysis. It won't be available.\n\nError:\n\n" + ex.ToString()); + } } } diff --git a/BizHawk.Common/InstanceDll.cs b/BizHawk.Common/InstanceDll.cs index a8aa1d0adc..f8e40ea96c 100644 --- a/BizHawk.Common/InstanceDll.cs +++ b/BizHawk.Common/InstanceDll.cs @@ -6,6 +6,9 @@ namespace BizHawk.Common { public class InstanceDll : IDisposable, IImportResolver { + [DllImport("kernel32.dll")] + public static extern UInt32 GetLastError(); + public InstanceDll(string dllPath) { // copy the dll to a temp directory @@ -24,6 +27,11 @@ namespace BizHawk.Common string envpath_new = Path.GetDirectoryName(path) + ";" + envpath; Environment.SetEnvironmentVariable("PATH", envpath_new, EnvironmentVariableTarget.Process); _hModule = LoadLibrary(path); //consider using LoadLibraryEx instead of shenanigans? + if (_hModule == IntPtr.Zero) + { + var lastError = GetLastError(); + throw new InvalidOperationException($"Failed to load plugin {path}, error code: 0x{lastError:X}"); + } var newfname = TempFileCleaner.RenameTempFilenameForDelete(path); File.Move(path, newfname); }