You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If a non-managed dll exists within the managed path, the preloader crashes with an accurate but unhelpful "System.BadImageFormatException: Format of the executable (.exe) or library (.dll) is invalid." message.
To Reproduce
Place any non-managed dll within a game's Managed folder
Expected behavior
The preloader to skip non-managed dll's, or handle the error better
Screenshots and logs
[Fatal : BepInEx] Could not run preloader!
[Fatal : BepInEx] System.BadImageFormatException: Format of the executable (.exe) or library (.dll) is invalid.
at Mono.Cecil.PE.ImageReader.ReadOptionalHeaders (System.UInt16& subsystem, System.UInt16& dll_characteristics) [0x000bb] in <02cd44f94ebd4355b3be9e1dbd9d77a1>:0
at Mono.Cecil.PE.ImageReader.ReadImage () [0x0008b] in <02cd44f94ebd4355b3be9e1dbd9d77a1>:0
at Mono.Cecil.PE.ImageReader.ReadImage (Mono.Disposable`1[T] stream, System.String file_name) [0x00007] in <02cd44f94ebd4355b3be9e1dbd9d77a1>:0
at Mono.Cecil.ModuleDefinition.ReadModule (Mono.Disposable`1[T] stream, System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00006] in <02cd44f94ebd4355b3be9e1dbd9d77a1>:0
at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x0006c] in <02cd44f94ebd4355b3be9e1dbd9d77a1>:0
at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName) [0x00007] in <02cd44f94ebd4355b3be9e1dbd9d77a1>:0
at Mono.Cecil.AssemblyDefinition.ReadAssembly (System.String fileName) [0x00000] in <02cd44f94ebd4355b3be9e1dbd9d77a1>:0
at BepInEx.Preloader.Patching.AssemblyPatcher.PatchAndLoad (System.String directory) [0x0001e] in <f7eb2f9c7412463299cd6eea6a3d029d>:0
at BepInEx.Preloader.Preloader.Run () [0x001f4] in <f7eb2f9c7412463299cd6eea6a3d029d>:0
Desktop (please complete the following information):
Game and game version: Issue is not game specific
BepInEx version: 5.0.0.171
Additional context
I've encountered this issue in a couple of games downloaded from Steam where additional dlls existed within the Managed folder, it's easy enough to detect and remove them but it would be better if the preloader could handle this situation better.
The text was updated successfully, but these errors were encountered:
Thanks for identifying this. It's related to the Mono.Cecil speculative loader not being able to handle unmanaged DLLs, unlike the old type loader implementation.
Will be fixed in v5.1.
If you want to use BepInEx in games with unmanaged assemblies in Managed folder before 5.1, please download bleeding edge build of BepInEx. Build 173 and newer should include the required fix.
Describe the bug
If a non-managed dll exists within the managed path, the preloader crashes with an accurate but unhelpful "System.BadImageFormatException: Format of the executable (.exe) or library (.dll) is invalid." message.
To Reproduce
Place any non-managed dll within a game's Managed folder
Expected behavior
The preloader to skip non-managed dll's, or handle the error better
Screenshots and logs
Desktop (please complete the following information):
Additional context
I've encountered this issue in a couple of games downloaded from Steam where additional dlls existed within the Managed folder, it's easy enough to detect and remove them but it would be better if the preloader could handle this situation better.
The text was updated successfully, but these errors were encountered: