1- using System ;
1+ using System ;
22using System . IO ;
33using System . Linq ;
44using System . Reflection ;
@@ -31,14 +31,16 @@ private static void LoadCriticalAssemblies()
3131 {
3232 foreach ( string criticalAssembly in CriticalAssemblies )
3333 {
34+ Console . Error . WriteLine ( $ "debug BepInEx Loading critical assembly { criticalAssembly } ") ;
3435 try
3536 {
3637 Assembly . LoadFile ( Path . Combine ( Paths . BepInExAssemblyDirectory , criticalAssembly ) ) ;
3738 }
38- catch ( Exception )
39+ catch ( Exception ex )
3940 {
4041 // Suppress error for now
4142 // TODO: Should we crash here if load fails? Can't use logging at this point
43+ Console . Error . WriteLine ( $ "err BepInEx Failed to load critical assembly: { ex } ") ;
4244 }
4345 }
4446 }
@@ -71,6 +73,8 @@ private static void PreloaderMain()
7173
7274 private static Assembly LocalResolve ( object sender , ResolveEventArgs args )
7375 {
76+ Console . Error . WriteLine ( $ "debug BepInEx Attempting local resolution of { args . Name } ") ;
77+
7478 if ( ! Utility . TryParseAssemblyName ( args . Name , out var assemblyName ) )
7579 return null ;
7680
@@ -84,13 +88,13 @@ private static Assembly LocalResolve(object sender, ResolveEventArgs args)
8488 . ToList ( ) ;
8589
8690 // First try to match by version, then just pick the best match (generally highest)
87- // This should mainly affect cases where the game itself loads some assembly (like Mono.Cecil)
91+ // This should mainly affect cases where the game itself loads some assembly (like Mono.Cecil)
8892 var foundMatch = validAssemblies . FirstOrDefault ( a => a . name . Version == assemblyName . Version ) ?? validAssemblies . FirstOrDefault ( ) ;
8993 var foundAssembly = foundMatch ? . assembly ;
9094
9195 if ( foundAssembly != null )
9296 return foundAssembly ;
93-
97+
9498 if ( Utility . TryResolveDllAssembly ( assemblyName , Paths . BepInExAssemblyDirectory , out foundAssembly )
9599 || Utility . TryResolveDllAssembly ( assemblyName , Paths . PatcherPluginPath , out foundAssembly )
96100 || Utility . TryResolveDllAssembly ( assemblyName , Paths . PluginPath , out foundAssembly ) )
@@ -112,15 +116,13 @@ internal static class Entrypoint
112116 /// </summary>
113117 public static void Start ( )
114118 {
115- // We set it to the current directory first as a fallback, but try to use the same location as the .exe file.
116- string silentExceptionLog = $ "preloader_{ DateTime . Now : yyyyMMdd_HHmmss_fff} .log";
119+ Console . Error . WriteLine ( "info BepInEx Starting" ) ;
117120
118121 try
119122 {
120123 EnvVars . LoadVars ( ) ;
121124
122125 string gamePath = Path . GetDirectoryName ( EnvVars . DOORSTOP_PROCESS_PATH ) ?? "." ;
123- silentExceptionLog = Path . Combine ( gamePath , silentExceptionLog ) ;
124126
125127 // Get the path of this DLL via Doorstop env var because Assembly.Location mangles non-ASCII characters on some versions of Mono for unknown reasons
126128 preloaderPath = Path . GetDirectoryName ( Path . GetFullPath ( EnvVars . DOORSTOP_INVOKE_DLL_PATH ) ) ;
@@ -135,7 +137,7 @@ public static void Start()
135137 }
136138 catch ( Exception ex )
137139 {
138- File . WriteAllText ( silentExceptionLog , ex . ToString ( ) ) ;
140+ Console . Error . WriteLine ( $ "fatal BepInEx { ex } " ) ;
139141 }
140142 finally
141143 {
@@ -158,4 +160,4 @@ internal static Assembly ResolveCurrentDirectory(object sender, ResolveEventArgs
158160 }
159161 }
160162 }
161- }
163+ }
0 commit comments