Add an early check for SMX.dll not loading.

master
Glenn Maynard 7 years ago
parent f321b7228d
commit 5d1e4c85fe
  1. 10
      smx-config/App.xaml.cs
  2. 2
      smx-config/SMX.cs

@ -15,8 +15,16 @@ namespace smx_config
{ {
AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionEventHandler; AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionEventHandler;
if(!SMX.SMX.DLLAvailable())
{
MessageBox.Show("SMXConfig encountered an unexpected error:\n\nSMX.dll failed to load.", "SMXConfig");
Current.Shutdown();
return;
}
if(Helpers.GetDebug()) if(Helpers.GetDebug())
SMX_Internal_OpenConsole(); SMX_Internal_OpenConsole();
CurrentSMXDevice.singleton = new CurrentSMXDevice(); CurrentSMXDevice.singleton = new CurrentSMXDevice();
} }
@ -32,6 +40,8 @@ namespace smx_config
// Shut down cleanly, to make sure we don't run any threaded callbacks during shutdown. // Shut down cleanly, to make sure we don't run any threaded callbacks during shutdown.
Console.WriteLine("Application exiting"); Console.WriteLine("Application exiting");
if(CurrentSMXDevice.singleton == null)
return;
CurrentSMXDevice.singleton.Shutdown(); CurrentSMXDevice.singleton.Shutdown();
CurrentSMXDevice.singleton = null; CurrentSMXDevice.singleton = null;
} }

@ -229,7 +229,7 @@ namespace SMX
private static extern bool SMX_ReenableAutoLights(); private static extern bool SMX_ReenableAutoLights();
// Check if the native DLL is available. This is mostly to avoid exceptions in the designer. // Check if the native DLL is available. This is mostly to avoid exceptions in the designer.
private static bool DLLAvailable() public static bool DLLAvailable()
{ {
return LoadLibrary("SMX.dll") != IntPtr.Zero; return LoadLibrary("SMX.dll") != IntPtr.Zero;
} }

Loading…
Cancel
Save