net-lisias-kspu / Kerbal-Joint-Reinforcement

Physics stabilizer plugin for Kerbal Space Program
http://ksp.lisias.net/add-ons/Kerbal-Joint-Reinforcement
GNU General Public License v3.0
10 stars 1 forks source link

ReflectionTypeLoadException: The classes in the module cannot be loaded with KSPe /L #8

Closed TheEventHorizon closed 5 years ago

TheEventHorizon commented 5 years ago

Currently there is this exception thrown by KSPe and your branch of KJR on scene load, clamp detachment and any other detachment events (stage separation, docking un-docking). There are two separate errors thrown which are listed below. I'll have the full log and my installed mods attached below as well. Thank you for your time.

KSP (1.6.1.2401) Kerbal Joint Reinforcement /L (3.4.0.4) KSP API Extensions /L (2.1.0.8)

[ERR 17:38:23.676] [KerbalJointReinforcement] ERROR: KerbalJointReinforcement.KJRManager raised Exception System.TypeInitializationException: An exception was thrown by the type initializer for KerbalJointReinforcement.KJRJointUtils ---> System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
  at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
  at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0 
  at KSPe.IO.File`1+<>c[KerbalJointReinforcement.KJRManager].<FullPathName>b__6_0 (System.Reflection.Assembly assembly) [0x00000] in <filename unknown>:0 
  at System.Linq.Enumerable+<CreateSelectManyIterator>c__Iterator14`3[System.Reflection.Assembly,System.Type,<>f__AnonymousType0`2[System.Reflection.Assembly,System.Type]].MoveNext () [0x00000] in <filename unknown>:0 
  at System.Linq.Enumerable+<CreateWhereIterator>c__Iterator1D`1[<>f__AnonymousType0`2[System.Reflection.Assembly,System.Type]].MoveNext () [0x00000] in <filename unknown>:0 
  at System.Linq.Enumerable+<CreateSelectIterator>c__Iterator10`2[<>f__AnonymousType0`2[System.Reflection.Assembly,System.Type],System.Type].MoveNext () [0x00000] in <filename unknown>:0 
  at System.Linq.Enumerable.FirstOrDefault[Type] (IEnumerable`1 source) [0x00000] in <filename unknown>:0 
  at KSPe.IO.File`1[KerbalJointReinforcement.KJRManager].FullPathName (System.String partialPathname, System.String hierarchy, Boolean createDirs) [0x00000] in <filename unknown>:0 
  at KSPe.IO.File`1+Data[KerbalJointReinforcement.KJRManager].FullPathName (System.String path, Boolean createDirs) [0x00000] in <filename unknown>:0 
  at KSPe.IO.Data.PluginConfiguration.CreateForType[KJRManager] (System.String filename) [0x00000] in <filename unknown>:0 
  at KerbalJointReinforcement.KJRJointUtils..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at KerbalJointReinforcement.KJRManager.Awake () [0x00000] in <filename unknown>:0 
[EXC 17:38:23.680] ReflectionTypeLoadException: The classes in the module cannot be loaded.
    System.Reflection.Assembly.GetTypes ()
    KSPe.IO.File`1+<>c[KerbalJointReinforcement.KJRManager].<FullPathName>b__6_0 (System.Reflection.Assembly assembly)
    System.Linq.Enumerable+<CreateSelectManyIterator>c__Iterator14`3[System.Reflection.Assembly,System.Type,<>f__AnonymousType0`2[System.Reflection.Assembly,System.Type]].MoveNext ()
    System.Linq.Enumerable+<CreateWhereIterator>c__Iterator1D`1[<>f__AnonymousType0`2[System.Reflection.Assembly,System.Type]].MoveNext ()
    System.Linq.Enumerable+<CreateSelectIterator>c__Iterator10`2[<>f__AnonymousType0`2[System.Reflection.Assembly,System.Type],System.Type].MoveNext ()
    System.Linq.Enumerable.FirstOrDefault[Type] (IEnumerable`1 source)
    KSPe.IO.File`1[KerbalJointReinforcement.KJRManager].FullPathName (System.String partialPathname, System.String hierarchy, Boolean createDirs)
    KSPe.IO.File`1+Data[KerbalJointReinforcement.KJRManager].FullPathName (System.String path, Boolean createDirs)
    KSPe.IO.Data.PluginConfiguration.CreateForType[KJRManager] (System.String filename)
    KerbalJointReinforcement.KJRJointUtils..cctor ()
    Rethrow as TypeInitializationException: An exception was thrown by the type initializer for KerbalJointReinforcement.KJRJointUtils
    KerbalJointReinforcement.KJRManager.Awake ()
    UnityEngine.Debug:LogException(Exception)
    KSPe.Util.Log.UnityLogger:logException(String, Exception)
    KSPe.Util.Log.Logger:error(Object, Exception)
    KerbalJointReinforcement.Log:ex(MonoBehaviour, Exception)
    KerbalJointReinforcement.KJRManager:Awake()
    UnityEngine.GameObject:AddComponent(Type)
    AddonLoader:StartAddon(LoadedAssembly, Type, KSPAddon, Startup)
    AddonLoader:StartAddons(Startup)
    AddonLoader:OnLevelLoaded(GameScenes)
    AddonLoader:OnSceneLoaded(Scene, LoadSceneMode)
    UnityEngine.SceneManagement.SceneManager:Internal_SceneLoaded(Scene, LoadSceneMode)

Log file and modlist: https://www.dropbox.com/sh/135i15f9798v8jj/AAChZmI2hZ7PtT683VhubrAra?dl=0

Lisias commented 5 years ago

There're some BIND ERRORs on your KSP.log. This happens when KSP tries to load an invalid or absent dependency (DLL). This somehow corrupts something on Mono's runtime, and then anyone trying to use Reflection borks this way.

KSPe makes heavy use of Reflection, so any problem on loading an DLL kills it - and then, everybody that needs KSPe dies too.

On your KSP.log, I found the following DLL problems:

[ERR 16:47:20.045] Failed to load assembly C:\SteamLibrary\steamapps\common\Kerbal Space Program\GameData\Principia\x64\libglog.dll:
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) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.PE.ImageReader.ReadImage () [0x00000] in <filename unknown>:0 
  at Mono.Cecil.PE.ImageReader.ReadImageFrom (System.IO.Stream stream) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.IO.Stream stream, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName) [0x00000] in <filename unknown>:0 
  at AssemblyLoader.ScanForBadTypeRefs (System.String file) [0x00000] in <filename unknown>:0 
  at AssemblyLoader.LoadExternalAssembly (System.String file) [0x00000] in <filename unknown>:0 

[LOG 16:47:20.048] Load(Assembly): Principia/x64/libprotobuf
[LOG 16:47:20.048] AssemblyLoader: Loading assembly at C:\SteamLibrary\steamapps\common\Kerbal Space Program\GameData\Principia\x64\libprotobuf.dll
[ERR 16:47:20.060] Failed to load assembly C:\SteamLibrary\steamapps\common\Kerbal Space Program\GameData\Principia\x64\libprotobuf.dll:
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) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.PE.ImageReader.ReadImage () [0x00000] in <filename unknown>:0 
  at Mono.Cecil.PE.ImageReader.ReadImageFrom (System.IO.Stream stream) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.IO.Stream stream, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName) [0x00000] in <filename unknown>:0 
  at AssemblyLoader.ScanForBadTypeRefs (System.String file) [0x00000] in <filename unknown>:0 
  at AssemblyLoader.LoadExternalAssembly (System.String file) [0x00000] in <filename unknown>:0 

[LOG 16:47:20.062] Load(Assembly): Principia/x64/physics
[LOG 16:47:20.062] AssemblyLoader: Loading assembly at C:\SteamLibrary\steamapps\common\Kerbal Space Program\GameData\Principia\x64\physics.dll
[ERR 16:47:20.069] Failed to load assembly C:\SteamLibrary\steamapps\common\Kerbal Space Program\GameData\Principia\x64\physics.dll:
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) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.PE.ImageReader.ReadImage () [0x00000] in <filename unknown>:0 
  at Mono.Cecil.PE.ImageReader.ReadImageFrom (System.IO.Stream stream) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.IO.Stream stream, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName) [0x00000] in <filename unknown>:0 
  at AssemblyLoader.ScanForBadTypeRefs (System.String file) [0x00000] in <filename unknown>:0 
  at AssemblyLoader.LoadExternalAssembly (System.String file) [0x00000] in <filename unknown>:0 

[LOG 16:47:20.071] Load(Assembly): Principia/x64/principia
[LOG 16:47:20.071] AssemblyLoader: Loading assembly at C:\SteamLibrary\steamapps\common\Kerbal Space Program\GameData\Principia\x64\principia.dll
[ERR 16:47:20.080] Failed to load assembly C:\SteamLibrary\steamapps\common\Kerbal Space Program\GameData\Principia\x64\principia.dll:
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) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.PE.ImageReader.ReadImage () [0x00000] in <filename unknown>:0 
  at Mono.Cecil.PE.ImageReader.ReadImageFrom (System.IO.Stream stream) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.IO.Stream stream, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName) [0x00000] in <filename unknown>:0 
  at AssemblyLoader.ScanForBadTypeRefs (System.String file) [0x00000] in <filename unknown>:0 
  at AssemblyLoader.LoadExternalAssembly (System.String file) [0x00000] in <filename unknown>:0 

[LOG 16:47:20.082] Load(Assembly): Principia/x64/serialization
[LOG 16:47:20.082] AssemblyLoader: Loading assembly at C:\SteamLibrary\steamapps\common\Kerbal Space Program\GameData\Principia\x64\serialization.dll
[ERR 16:47:20.097] Failed to load assembly C:\SteamLibrary\steamapps\common\Kerbal Space Program\GameData\Principia\x64\serialization.dll:
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) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.PE.ImageReader.ReadImage () [0x00000] in <filename unknown>:0 
  at Mono.Cecil.PE.ImageReader.ReadImageFrom (System.IO.Stream stream) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.IO.Stream stream, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName) [0x00000] in <filename unknown>:0 
  at AssemblyLoader.ScanForBadTypeRefs (System.String file) [0x00000] in <filename unknown>:0 
  at AssemblyLoader.LoadExternalAssembly (System.String file) [0x00000] in <filename unknown>:0 

and also

[ERR 16:47:21.274] ADDON BINDER: Cannot resolve assembly: KSPUtil, Culture=neutral, PublicKeyToken=null

[ERR 16:47:21.274] ADDON BINDER: Cannot resolve assembly: KSPUtil, Culture=neutral, PublicKeyToken=null

[ERR 16:47:21.275] AssemblyLoader: Exception loading 'EvaFollower': System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
  at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
  at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0 
  at AssemblyLoader.LoadAssemblies () [0x00000] in <filename unknown>:0 

Fixing (or deleting) Principia and EvaFollower will fix the ADDON BINDER errors, and so KSPe will work as expected. EvaFollower apparently needs KSPUtil, and it's missing.

Lisias commented 5 years ago

Tagging as "invalid' because this problem is unrelated to KJR. It's a known bug on Mono's runtime, affecting KSPe than by its turn borks KJR.