janxious / BattleTechModLoader

A simple mod loader and injector for HBS's PC game BattleTech.
The Unlicense
15 stars 1 forks source link

Pause on injection error? #12

Closed Sheep-y closed 5 years ago

Sheep-y commented 5 years ago

Would be nice if the injector can pause on error ("Press any key to continue"), for example when the dll is being locked by dnSpy and the injector is executed from windows explorer instead of console.

janxious commented 5 years ago

What is the nature of the error when the dll is locked?

Sheep-y commented 5 years ago

Win 10 Home 64 bit, BTML 0.6.4

Assembly-CSharp.dll backed up to Assembly-CSharp.dll.orig
Injecting Assembly-CSharp.dll with BattleTechModLoader.BTModLoader.Init at BattleTech.Main.Start
Writing back to Assembly-CSharp.dll...
ERROR: An exception occured: System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.SetLengthCore(Int64 value)
   at System.IO.FileStream.SetLength(Int64 value)
   at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
   at Mono.Cecil.ModuleWriter.WriteModule(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
   at Mono.Cecil.ModuleDefinition.Write(Stream stream, WriterParameters parameters)
   at Mono.Cecil.ModuleDefinition.Write(WriterParameters parameters)
   at BattleTechModLoader.BTMLInjector.WriteNewAssembly(String hookFilePath, ModuleDefinition game)
   at BattleTechModLoader.BTMLInjector.Inject(String hookFilePath, String injectFilePath)
   at BattleTechModLoader.BTMLInjector.Main(String[] args)

The injector then terminates, so the error cannot be seen except in command prompt.

jegelstaff commented 5 years ago

In Windows 8.1, with the 0.6.4 download from https://github.com/janxious/BattleTechModLoader/releases

ERROR: An exception occured: System.IO.FileNotFoundException: Could not load file or assembly 'System.IO.FileSystem.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.IO.FileSystem.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 
at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) 
at BattleTechModLoader.BTMLInjector.IsInjected(String dllPath, Boolean& isCurrentInjection, String& gameVersion) 
at BattleTechModLoader.BTMLInjector.Main(String[] args)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].