diff --git a/SourceGen/AppForms/ProjectView.cs b/SourceGen/AppForms/ProjectView.cs index 89aa253..2b3c8d1 100644 --- a/SourceGen/AppForms/ProjectView.cs +++ b/SourceGen/AppForms/ProjectView.cs @@ -200,15 +200,21 @@ namespace SourceGen.AppForms { Properties.Resources.RUNTIME_DIR_NOT_FOUND_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); + return; } try { PluginDllCache.PreparePluginDir(); } catch (Exception ex) { + string pluginPath = PluginDllCache.GetPluginDirPath(); + if (pluginPath == null) { + pluginPath = ""; + } string msg = string.Format(Properties.Resources.PLUGIN_DIR_FAIL, - PluginDllCache.GetPluginDirPath() + ": " + ex.Message); + pluginPath + ": " + ex.Message); MessageBox.Show(msg, Properties.Resources.PLUGIN_DIR_FAIL_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); + return; } logoPictureBox.ImageLocation = RuntimeDataAccess.GetPathName(LOGO_FILE_NAME); diff --git a/SourceGen/RuntimeDataAccess.cs b/SourceGen/RuntimeDataAccess.cs index 1e60ff2..7c0f43c 100644 --- a/SourceGen/RuntimeDataAccess.cs +++ b/SourceGen/RuntimeDataAccess.cs @@ -38,7 +38,10 @@ namespace SourceGen { return sBasePath; } - string exeName = Process.GetCurrentProcess().MainModule.FileName; + // Process.GetCurrentProcess().MainModule.FileName returns "/usr/bin/mono-sgen" + // under Linux, which is not what we want. Since this class is part of the main + // executable, we can use our own assembly location to get the desired answer. + string exeName = typeof(RuntimeDataAccess).Assembly.Location; string baseDir = Path.GetDirectoryName(exeName); if (string.IsNullOrEmpty(baseDir)) { return null; diff --git a/SourceGen/Sandbox/PluginDllCache.cs b/SourceGen/Sandbox/PluginDllCache.cs index 8396c8c..93a4ff7 100644 --- a/SourceGen/Sandbox/PluginDllCache.cs +++ b/SourceGen/Sandbox/PluginDllCache.cs @@ -63,10 +63,14 @@ namespace SourceGen.Sandbox { /// /// Computes the path to the plugin directory. Does not attempt to verify that it exists. /// - /// Plugin directory path. + /// Plugin directory path, or null if we can't find the application data + /// area. public static string GetPluginDirPath() { if (sPluginDirPath == null) { string runtimeUp = Path.GetDirectoryName(RuntimeDataAccess.GetDirectory()); + if (runtimeUp == null) { + return null; + } sPluginDirPath = Path.Combine(runtimeUp, PLUGIN_DIR_NAME); } return sPluginDirPath;