Better handling of assembly loader

This commit is contained in:
Flamefire committed 2014-08-08 16:07:27 +02:00
1 parent cb40cdcd92
commit 7b95942653
2 files changed
+15 -14

No files matched your search

+3 -1
View File
@@ -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";
+12 -13
View File
@@ -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");