mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
Add more error information to TypeLoader
This commit is contained in:
1 parent
2c183343d3
commit
5179507da0
1 file changed
+22
-1
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user