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:
adelikat 2013-11-03 16:05:49 +00:00
parent 75ef046927
commit 26ffd9f4e3
2 changed files with 8 additions and 8 deletions

View File

@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.IO;
using System.Reflection;
namespace BizHawk.Client.Common
{
@ -8,7 +9,7 @@ namespace BizHawk.Client.Common
{
public static string GetExeDirectoryAbsolute()
{
string path = AppDomain.CurrentDomain.BaseDirectory;
string path = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location);
if (path.EndsWith(Path.DirectorySeparatorChar.ToString()))
{
path = path.Remove(path.Length - 1, 1);
@ -28,8 +29,7 @@ namespace BizHawk.Client.Common
{
get
{
string blah = MakeProgramRelativePath("config.ini");
return blah;
return MakeProgramRelativePath("config.ini");
}
}

View File

@ -24,7 +24,7 @@ namespace BizHawk.Client.EmuHawk
//http://www.codeproject.com/Articles/310675/AppDomain-AssemblyResolve-Event-Tips
#if WINDOWS
// 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);
//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)
{
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;
if (thisversion != utilversion || thisversion != emulversion)
@ -66,9 +66,9 @@ namespace BizHawk.Client.EmuHawk
Application.EnableVisualStyles();
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();
BizHawk.Common.HawkFile.ArchiveHandlerFactory = new SevenZipSharpArchiveHandler();
#if WINDOWS
@ -193,7 +193,7 @@ namespace BizHawk.Client.EmuHawk
//load missing assemblies by trying to find them in the dll directory
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);
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