diff --git a/smx-config/App.xaml.cs b/smx-config/App.xaml.cs index 24ac412..ac9b66f 100644 --- a/smx-config/App.xaml.cs +++ b/smx-config/App.xaml.cs @@ -15,8 +15,16 @@ namespace smx_config { 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()) SMX_Internal_OpenConsole(); + 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. Console.WriteLine("Application exiting"); + if(CurrentSMXDevice.singleton == null) + return; CurrentSMXDevice.singleton.Shutdown(); CurrentSMXDevice.singleton = null; } diff --git a/smx-config/SMX.cs b/smx-config/SMX.cs index 4aa2130..48c2908 100644 --- a/smx-config/SMX.cs +++ b/smx-config/SMX.cs @@ -229,7 +229,7 @@ namespace SMX private static extern bool SMX_ReenableAutoLights(); // 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; }