diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs index 3de72e98..0973386a 100644 --- a/Vocaluxe/Base/CSettings.cs +++ b/Vocaluxe/Base/CSettings.cs @@ -71,10 +71,12 @@ namespace Vocaluxe.Base public const int VertexBufferElements = 10000; + public static readonly string ProgramFolder = AppDomain.CurrentDomain.BaseDirectory; + #if INSTALLER public static readonly string DataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Vocaluxe"); #else - public static readonly string DataPath = Environment.CurrentDirectory; + public static readonly string DataPath = ProgramFolder; #endif public const string Icon = "Vocaluxe.ico"; diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs index de49bff9..b4720e87 100644 --- a/Vocaluxe/Program.cs +++ b/Vocaluxe/Program.cs @@ -301,6 +301,7 @@ namespace Vocaluxe if (args.Name.IndexOf(".resources", StringComparison.Ordinal) >= 0) return null; + Assembly assembly = null; string[] arr = args.Name.Split(new char[] {','}); if (arr.Length > 0) { @@ -311,27 +312,25 @@ namespace Vocaluxe #if ARCH_X64 string path = "x64"; #endif - path = Path.Combine(path, arr[0] + ".dll"); + path = Path.Combine(CSettings.ProgramFolder, path, arr[0] + ".dll"); try { - Assembly assembly; + assembly = Assembly.LoadFrom(path); + } + catch (FileLoadException e1) + { + //possibly loading from network, this would work always but better use the normal LoadFrom for more specific errors try { - assembly = Assembly.LoadFrom(path); - } - catch (FileLoadException) - { - //possibly loading from network, this would work always but better use the normal LoadFrom for more specific errors assembly = Assembly.Load(File.ReadAllBytes(path)); } - return assembly; - } - catch (Exception e) - { - CLog.LogError("Cannot load assembly " + args.Name + " from " + path + ": " + e); + catch (Exception e) + { + CLog.LogError("Cannot load assembly " + args.Name + " from " + path + ": " + e + "\r\nOuter Error: " + e1); + } } } - return null; + return assembly; } private static readonly Mutex _Mutex = new Mutex(false, Application.ProductName + "-SingleInstanceMutex");