Add more error information to TypeLoader

This commit is contained in:
ManlyMarco committed 2018-11-25 23:05:07 +01:00
1 parent 2c183343d3
commit 5179507da0
1 file changed
+22 -1
+22 -1
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;
using BepInEx.Logging;
namespace BepInEx.Bootstrap
@@ -36,13 +37,33 @@ namespace BepInEx.Bootstrap
}
}
catch (BadImageFormatException) { } //unmanaged DLL
catch (ReflectionTypeLoadException)
catch (ReflectionTypeLoadException ex)
{
Logger.Log(LogLevel.Error, $"Could not load \"{Path.GetFileName(dll)}\" as a plugin!");
Logger.Log(LogLevel.Debug, TypeLoadExceptionToString(ex));
}
}
return types;
}
private static string TypeLoadExceptionToString(ReflectionTypeLoadException ex)
{
StringBuilder sb = new StringBuilder();
foreach (Exception exSub in ex.LoaderExceptions)
{
sb.AppendLine(exSub.Message);
if (exSub is FileNotFoundException exFileNotFound)
{
if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
{
sb.AppendLine("Fusion Log:");
sb.AppendLine(exFileNotFound.FusionLog);
}
}
sb.AppendLine();
}
return sb.ToString();
}
}
}