diff --git a/IPA.Injector/Injector.cs b/IPA.Injector/Injector.cs
index 6a05dec4..e8fd0512 100644
--- a/IPA.Injector/Injector.cs
+++ b/IPA.Injector/Injector.cs
@@ -8,6 +8,7 @@ using System;
using System.IO;
using System.Linq;
using System.Reflection;
+using System.Runtime.ExceptionServices;
using System.Threading.Tasks;
using UnityEngine;
using static IPA.Logging.Logger;
@@ -54,7 +55,34 @@ namespace IPA.Injector
loader.Debug("Prepping bootstrapper");
- InstallBootstrapPatch();
+ // The whole mess that follows is an attempt to work around Mono failing to
+ // call the library load routine for Mono.Cecil when the debugger is attached.
+ bool runProperly = false;
+ while (!runProperly) // retry until it finishes, or errors
+ try
+ {
+ InstallBootstrapPatch();
+ runProperly = true;
+ }
+ catch (FileNotFoundException e)
+ {
+ var asmName = e.FileName;
+
+ AssemblyName name;
+ try
+ { // try to parse as an AssemblyName, if it isn't, rethrow the outer exception
+ name = new AssemblyName(asmName);
+ }
+ catch (Exception)
+ {
+ ExceptionDispatchInfo.Capture(e).Throw();
+ throw;
+ }
+
+ // name is failed lookup, try to manually load it
+ LibLoader.AssemblyLibLoader(null,
+ new ResolveEventArgs(name.FullName, Assembly.GetExecutingAssembly()));
+ }
Updates.InstallPendingUpdates();
@@ -205,9 +233,9 @@ namespace IPA.Injector
Application.logMessageReceived += delegate (string condition, string stackTrace, LogType type)
{
- var level = UnityLogInterceptor.LogTypeToLevel(type);
- UnityLogInterceptor.UnityLogger.Log(level, $"{condition.Trim()}");
- UnityLogInterceptor.UnityLogger.Log(level, $"{stackTrace.Trim()}");
+ var level = UnityLogRedirector.LogTypeToLevel(type);
+ UnityLogProvider.UnityLogger.Log(level, $"{condition.Trim()}");
+ UnityLogProvider.UnityLogger.Log(level, $"{stackTrace.Trim()}");
};
// need to reinit streams singe Unity seems to redirect stdout
diff --git a/IPA.Loader/IPA.Loader.csproj b/IPA.Loader/IPA.Loader.csproj
index 61ccb5e1..3f382f65 100644
--- a/IPA.Loader/IPA.Loader.csproj
+++ b/IPA.Loader/IPA.Loader.csproj
@@ -62,7 +62,8 @@
-
+
+
@@ -87,7 +88,7 @@
-
+
diff --git a/IPA.Loader/Logging/Logger.cs b/IPA.Loader/Logging/Logger.cs
index 00fc1790..fe4409ef 100644
--- a/IPA.Loader/Logging/Logger.cs
+++ b/IPA.Loader/Logging/Logger.cs
@@ -25,7 +25,7 @@ namespace IPA.Logging
internal static Logger libLoader => log.GetChildLogger("LibraryLoader");
internal static Logger loader => log.GetChildLogger("Loader");
internal static Logger config => log.GetChildLogger("Config");
- internal static bool LogCreated => _log != null || UnityLogInterceptor.Logger != null;
+ internal static bool LogCreated => _log != null || UnityLogProvider.Logger != null;
///
/// The standard format for log messages.
diff --git a/IPA.Loader/Logging/UnityLogInterceptor.cs b/IPA.Loader/Logging/UnityLogProvider.cs
similarity index 89%
rename from IPA.Loader/Logging/UnityLogInterceptor.cs
rename to IPA.Loader/Logging/UnityLogProvider.cs
index 3f36918f..4bb8af41 100644
--- a/IPA.Loader/Logging/UnityLogInterceptor.cs
+++ b/IPA.Loader/Logging/UnityLogProvider.cs
@@ -2,11 +2,14 @@
namespace IPA.Logging
{
- internal static class UnityLogInterceptor
+ internal static class UnityLogProvider
{
internal static Logger Logger;
public static Logger UnityLogger => Logger ?? (Logger = new StandardLogger("UnityEngine"));
+ }
+ internal static class UnityLogRedirector
+ {
public static Logger.Level LogTypeToLevel(LogType type)
{
switch (type)
diff --git a/Refs/UnityEngine.CoreModule.dll b/Refs/UnityEngine.CoreModule.dll
index a802a5c6..0913c47b 100644
Binary files a/Refs/UnityEngine.CoreModule.dll and b/Refs/UnityEngine.CoreModule.dll differ