Add an early check for SMX.dll not loading.

This commit is contained in:
Glenn Maynard 2018-06-07 16:01:38 -05:00
parent f321b7228d
commit 5d1e4c85fe
2 changed files with 11 additions and 1 deletions

View File

@ -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;
}

View File

@ -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;
}