1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-06-13 14:29:30 +00:00

Improve chances of running under Mono

Updated the RuntimeData directory finder to work, and made the
stuff that crashed when the directory wasn't found crash in less
obvious ways.  Under Mono+Linux it still falls over with some
complaints about ListViews.  This will need some work.
This commit is contained in:
Andy McFadden 2018-10-01 10:24:23 -07:00
parent 11174b8e75
commit 60aa252352
3 changed files with 16 additions and 3 deletions

View File

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

View File

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

View File

@ -63,10 +63,14 @@ namespace SourceGen.Sandbox {
/// <summary>
/// Computes the path to the plugin directory. Does not attempt to verify that it exists.
/// </summary>
/// <returns>Plugin directory path.</returns>
/// <returns>Plugin directory path, or null if we can't find the application data
/// area.</returns>
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;