EmuHawk - don't use PathManager to resolve the exe directory during main now that it is in a dll, it can find its own path itself
This commit is contained in:
parent
75ef046927
commit
26ffd9f4e3
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace BizHawk.Client.Common
|
namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
|
@ -8,7 +9,7 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
public static string GetExeDirectoryAbsolute()
|
public static string GetExeDirectoryAbsolute()
|
||||||
{
|
{
|
||||||
string path = AppDomain.CurrentDomain.BaseDirectory;
|
string path = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location);
|
||||||
if (path.EndsWith(Path.DirectorySeparatorChar.ToString()))
|
if (path.EndsWith(Path.DirectorySeparatorChar.ToString()))
|
||||||
{
|
{
|
||||||
path = path.Remove(path.Length - 1, 1);
|
path = path.Remove(path.Length - 1, 1);
|
||||||
|
@ -28,8 +29,7 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
string blah = MakeProgramRelativePath("config.ini");
|
return MakeProgramRelativePath("config.ini");
|
||||||
return blah;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
//http://www.codeproject.com/Articles/310675/AppDomain-AssemblyResolve-Event-Tips
|
//http://www.codeproject.com/Articles/310675/AppDomain-AssemblyResolve-Event-Tips
|
||||||
#if WINDOWS
|
#if WINDOWS
|
||||||
// this will look in subdirectory "dll" to load pinvoked stuff
|
// this will look in subdirectory "dll" to load pinvoked stuff
|
||||||
string dllDir = System.IO.Path.Combine(PathManager.GetExeDirectoryAbsolute(), "dll");
|
string dllDir = System.IO.Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dll");
|
||||||
SetDllDirectory(dllDir);
|
SetDllDirectory(dllDir);
|
||||||
|
|
||||||
//but before we even try doing that, whack the MOTW from everything in that directory (thats a dll)
|
//but before we even try doing that, whack the MOTW from everything in that directory (thats a dll)
|
||||||
|
@ -53,7 +53,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (!MainForm.INTERIM)
|
if (!MainForm.INTERIM)
|
||||||
{
|
{
|
||||||
var thisversion = typeof(Program).Assembly.GetName().Version;
|
var thisversion = typeof(Program).Assembly.GetName().Version;
|
||||||
var utilversion = Assembly.LoadWithPartialName("Bizhawk.Util").GetName().Version;
|
var utilversion = Assembly.LoadWithPartialName("Bizhawk.Client.Common").GetName().Version;
|
||||||
var emulversion = Assembly.LoadWithPartialName("Bizhawk.Emulation").GetName().Version;
|
var emulversion = Assembly.LoadWithPartialName("Bizhawk.Emulation").GetName().Version;
|
||||||
|
|
||||||
if (thisversion != utilversion || thisversion != emulversion)
|
if (thisversion != utilversion || thisversion != emulversion)
|
||||||
|
@ -66,9 +66,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
|
||||||
Global.Config = ConfigService.Load<Config>(PathManager.DefaultIniPath, new Config());
|
string iniPath = System.IO.Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.ini");
|
||||||
|
Global.Config = ConfigService.Load<Config>(iniPath, new Config());
|
||||||
Global.Config.ResolveDefaults();
|
Global.Config.ResolveDefaults();
|
||||||
|
|
||||||
BizHawk.Common.HawkFile.ArchiveHandlerFactory = new SevenZipSharpArchiveHandler();
|
BizHawk.Common.HawkFile.ArchiveHandlerFactory = new SevenZipSharpArchiveHandler();
|
||||||
|
|
||||||
#if WINDOWS
|
#if WINDOWS
|
||||||
|
@ -193,7 +193,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
//load missing assemblies by trying to find them in the dll directory
|
//load missing assemblies by trying to find them in the dll directory
|
||||||
string dllname = new AssemblyName(args.Name).Name + ".dll";
|
string dllname = new AssemblyName(args.Name).Name + ".dll";
|
||||||
string directory = Path.Combine(PathManager.GetExeDirectoryAbsolute(), "dll");
|
string directory = System.IO.Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dll");
|
||||||
string fname = Path.Combine(directory, dllname);
|
string fname = Path.Combine(directory, dllname);
|
||||||
if (!File.Exists(fname)) return null;
|
if (!File.Exists(fname)) return null;
|
||||||
//it is important that we use LoadFile here and not load from a byte array; otherwise mixed (managed/unamanged) assemblies can't load
|
//it is important that we use LoadFile here and not load from a byte array; otherwise mixed (managed/unamanged) assemblies can't load
|
||||||
|
|
Loading…
Reference in New Issue