Better handling of assembly loader
This commit is contained in:
1 parent
cb40cdcd92
commit
7b95942653
2 files changed
+11
-10
No files matched your search
@@ -71,10 +71,12 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
public const int VertexBufferElements = 10000;
|
public const int VertexBufferElements = 10000;
|
||||||
|
|
||||||
|
public static readonly string ProgramFolder = AppDomain.CurrentDomain.BaseDirectory;
|
||||||
|
|
||||||
#if INSTALLER
|
#if INSTALLER
|
||||||
public static readonly string DataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Vocaluxe");
|
public static readonly string DataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Vocaluxe");
|
||||||
#else
|
#else
|
||||||
public static readonly string DataPath = Environment.CurrentDirectory;
|
public static readonly string DataPath = ProgramFolder;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public const string Icon = "Vocaluxe.ico";
|
public const string Icon = "Vocaluxe.ico";
|
||||||
|
|||||||
+8
-9
@@ -301,6 +301,7 @@ namespace Vocaluxe
|
|||||||
if (args.Name.IndexOf(".resources", StringComparison.Ordinal) >= 0)
|
if (args.Name.IndexOf(".resources", StringComparison.Ordinal) >= 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
Assembly assembly = null;
|
||||||
string[] arr = args.Name.Split(new char[] {','});
|
string[] arr = args.Name.Split(new char[] {','});
|
||||||
if (arr.Length > 0)
|
if (arr.Length > 0)
|
||||||
{
|
{
|
||||||
@@ -311,27 +312,25 @@ namespace Vocaluxe
|
|||||||
#if ARCH_X64
|
#if ARCH_X64
|
||||||
string path = "x64";
|
string path = "x64";
|
||||||
#endif
|
#endif
|
||||||
path = Path.Combine(path, arr[0] + ".dll");
|
path = Path.Combine(CSettings.ProgramFolder, path, arr[0] + ".dll");
|
||||||
try
|
|
||||||
{
|
|
||||||
Assembly assembly;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
assembly = Assembly.LoadFrom(path);
|
assembly = Assembly.LoadFrom(path);
|
||||||
}
|
}
|
||||||
catch (FileLoadException)
|
catch (FileLoadException e1)
|
||||||
{
|
{
|
||||||
//possibly loading from network, this would work always but better use the normal LoadFrom for more specific errors
|
//possibly loading from network, this would work always but better use the normal LoadFrom for more specific errors
|
||||||
|
try
|
||||||
|
{
|
||||||
assembly = Assembly.Load(File.ReadAllBytes(path));
|
assembly = Assembly.Load(File.ReadAllBytes(path));
|
||||||
}
|
}
|
||||||
return assembly;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
CLog.LogError("Cannot load assembly " + args.Name + " from " + path + ": " + 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");
|
private static readonly Mutex _Mutex = new Mutex(false, Application.ProductName + "-SingleInstanceMutex");
|
||||||
|
|||||||
Reference in new issue
Block a user