KSP-ModularManagement / KSPe

Extensions and utilities for Kerbal Space Program
http://ksp.lisias.net/add-ons/KSPAPIExtensions
Other
11 stars 5 forks source link

Missing class: The type Initializer for 'KSPe.IO.Hierarchy 1' threw an exception error #25

Closed egrochka closed 2 years ago

egrochka commented 2 years ago

Hi, @Lisias

I'm also getting the Missing class: The type Initializer for 'KSPe.IO.Hierarchy 1' threw an exception error when starting ksp.

I tried the other solutions found here but none of them worked for me.

Note: I'm not using windows, i run the game trough proton on manjaro linux.

KSP.log

Lisias commented 2 years ago

Humm…. interesting….

You have the first valid "Missing file" problem this exception has ever logged! :)

This is what's happening:

[LOG 15:06:25.368] [KSPe.Globals] INFO: KSPe.cfg does not exists. Using defaults.
[LOG 15:06:25.370] [AddonLoader]: Instantiating addon 'Startup' from assembly 'DistantObject'
[EXC 15:06:25.862] ArgumentException: Illegal characters in path.
        System.IO.Path.CheckInvalidPathChars (System.String path, System.Boolean checkAdditional) (at <9577ac7a62ef43179789031239ba8798>:0)
        System.IO.Path.InternalCombine (System.String path1, System.String path2) (at <9577ac7a62ef43179789031239ba8798>:0)
        System.IO.FileSystemEnumerableIterator`1[TSource].CreateSearchResult (System.IO.Directory+SearchData localSearchData, Microsoft.Win32.
        System.IO.FileSystemEnumerableIterator`1[TSource].MoveNext () (at <9577ac7a62ef43179789031239ba8798>:0)
        System.Collections.Generic.List`1[T]..ctor (System.Collections.Generic.IEnumerable`1[T] collection) (at <9577ac7a62ef43179789031239ba8
        System.IO.Directory.InternalGetFileDirectoryNames (System.String path, System.String userPathOriginal, System.String searchPattern, Sy
        System.IO.Directory.InternalGetDirectories (System.String path, System.String searchPattern, System.IO.SearchOption searchOption) (at
        System.IO.Directory.GetDirectories (System.String path, System.String searchPattern, System.IO.SearchOption searchOption) (at <9577ac7
        KSPe.IO.Path.Origin () (at <9f7cd9a529194dc4a60f3cf218f8503b>:0)
        KSPe.Util.Installation.CheckForWrongDirectoy (System.Type type, System.String name, System.String folder, System.String vendor) (at <9
        KSPe.Util.Installation.Check[T] (System.String name, System.String folder, System.String vendor, System.Boolean unique) (at <9f7cd9a52
        KSPe.Util.Installation.Check[T] (System.Type versionClass, System.Boolean unique) (at <9f7cd9a529194dc4a60f3cf218f8503b>:0)
        KSPe.Util.Installation.Check[T] (System.Boolean unique) (at <9f7cd9a529194dc4a60f3cf218f8503b>:0)
        KSPe.Util.Installation.Check[T] () (at <9f7cd9a529194dc4a60f3cf218f8503b>:0)
        DistantObject.Startup.Awake () (at <e30ec9083ad44f3d8c362bd51ed054ea>:0)
        UnityEngine.DebugLogHandler:LogException(Exception, Object)
        ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
        UnityEngine.GameObject:AddComponent(Type)
        AddonLoader:StartAddon(LoadedAssembly, Type, KSPAddon, Startup)
        AddonLoader:StartAddons(Startup)
        <LoadObjects>d__90:MoveNext()
        UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
        <CreateDatabase>d__71:MoveNext()
        UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
        GameDatabase:StartLoad()
        <LoadSystems>d__11:MoveNext()
        UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
        LoadingScreen:Start()

When KSPe.Light tries to check if the DLL is installed on the right place (and both TweakScale and DOE uses it), it builds the pathname using the C#'s System calls. Since you are using Proton under Linux, the Mono runtime must be thinking you are under Windows, where the path separator is a "\" (counter-slash) character. But on UNIX, the path separator is the "/" (slash).

So we have part of the code building paths as they where in Windows, and part of the code borking because they are trying to use them on a UNIX-like environment.

This caught me with my pants down - it was my understanding that Proton somehow would be handling this. I did a check on KSPe's code to see if I could find some "/" or "\" hardcoded, but I'm using SIO.Path.DirectorySeparatorChar on everything.

So I think we found a bug on Proton - or at least, in how it handles the Mono runtime...

egrochka commented 2 years ago

Thanks!

Just tried to run the native version and it works fine, so it really is a proton bug. Also tried different proton versions and got the same issue on all of them. I'll guess it's kind of impossible to fix this now?

Lisias commented 2 years ago

@egrochka

Thanks!

Welcome!

Just tried to run the native version and it works fine, so it really is a proton bug. Also tried different proton versions and got the same issue on all of them. I'll guess it's kind of impossible to fix this now?

It's not up to me to fix, it's something the Proton guys need to address somehow - at very least, to tell me what I can do to workaround the problem on my side.

I'm kinda of "hostage" of the Mono's runtime, I'm completely relying on it to handle the differences between Operating Systems!

Lisias commented 2 years ago

I'm moving this to KSPApiExtension, as this is related to it anyway.

hendrack commented 2 years ago

Long time no see :)

Now that I have migrated to linux again, I don't think this is a proton bug, but rather mono, because I get this as well with the native linux version and latest Recall/MM/KSPApiExtension:

[EXC 14:11:08.302] Exception: Magic number is wrong: 542 System.TermInfoReader.ReadHeader (System.Byte[] buffer, System.Int32& position) (at <9577ac7a62ef43179789031239ba8798>:0) System.TermInfoReader..ctor (System.String term, System.String filename) (at <9577ac7a62ef43179789031239ba8798>:0) System.TermInfoDriver..ctor (System.String term) (at <9577ac7a62ef43179789031239ba8798>:0) System.ConsoleDriver.CreateTermInfoDriver (System.String term) (at <9577ac7a62ef43179789031239ba8798>:0) System.ConsoleDriver..cctor () (at <9577ac7a62ef43179789031239ba8798>:0) Rethrow as TypeInitializationException: The type initializer for 'System.ConsoleDriver' threw an exception. System.Console.SetupStreams (System.Text.Encoding inputEncoding, System.Text.Encoding outputEncoding) (at <9577ac7a62ef43179789031239ba8798>:0) System.Console..cctor () (at <9577ac7a62ef43179789031239ba8798>:0) Rethrow as TypeInitializationException: The type initializer for 'System.Console' threw an exception. System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) (at :0) System.Diagnostics.Process.Start () (at :0) (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start() KSPe.Multiplatform.Shell.command (System.String command, System.String commandline) (at <05f81ffbee73404ba435226cd87dcc0c>:0) KSPe.Multiplatform.FileSystem.Reparse_readlink (System.String path) (at <05f81ffbee73404ba435226cd87dcc0c>:0) KSPe.Multiplatform.FileSystem.ReparsePath (System.String path) (at <05f81ffbee73404ba435226cd87dcc0c>:0) KSPe.IO.Directory.RealPath (System.String path) (at <05f81ffbee73404ba435226cd87dcc0c>:0) KSPe.IO.Directory.Exists (System.String path) (at <05f81ffbee73404ba435226cd87dcc0c>:0) KSPe.IO.Path.EnsureTrailingSeparatorOnDir (System.String path, System.Boolean blindlyAppend) (at <05f81ffbee73404ba435226cd87dcc0c>:0) KSPe.IO.Path.Combine (System.String path1, System.String path2) (at <05f81ffbee73404ba435226cd87dcc0c>:0) KSPe.IO.Hierarchy..cctor () (at <05f81ffbee73404ba435226cd87dcc0c>:0) Rethrow as TypeInitializationException: The type initializer for 'KSPe.IO.Hierarchy' threw an exception. KSPe.Util.SystemTools+Assembly+Loader..ctor (System.String namespaceOverride, System.String[] subdirs) (at <05f81ffbee73404ba435226cd87dcc0c>:0) KSPe.UI.Startup.Awake () (at <47d41d569738492196e4d2b03803cdd0>:0) Rethrow as TypeInitializationException: The type initializer for 'KSPe.IO.Hierarchy1' threw an exception. KSPe.IO.File1+Data[T].FullPathName (System.Boolean createDirs, System.String fn, System.String[] fns) (at <05f81ffbee73404ba435226cd87dcc0c>:0) KSPe.IO.Data`1+ConfigNode[T].For (System.String name, System.String filename) (at <05f81ffbee73404ba435226cd87dcc0c>:0) ModuleManager.FilePathRepository..cctor () (at <60b0b7653af84cb3871e096a9317f5a6>:0) Rethrow as TypeInitializationException: The type initializer for 'ModuleManager.FilePathRepository' threw an exception. ModuleManager.MMPatchRunner+<>cDisplayClass13_0.b0 () (at <60b0b7653af84cb3871e096a9317f5a6>:0) ModuleManager.Threading.BackgroundTask+<>cDisplayClass0_0.gRunAction|0 () (at <60b0b7653af84cb3871e096a9317f5a6>:0) UnityEngine.DebugLogHandler:LogException(Exception, Object) KSPe.Util.Log.UnityLogDecorator:UnityEngine.ILogHandler.LogException(Exception, Object) ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object) UnityEngine.Debug:LogException(Exception) KSPe.Util.Log.UnityLogger:logException(String, Exception) KSPe.Util.Log.Logger:error(Exception, String, Object[]) ModuleManager.Logging.ModLogger:Exception(String, Exception) ModuleManager.d__13:MoveNext() UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

Lisias commented 2 years ago

@hendrack

Long time no see :)

Hi! :)

Now that I have migrated to linux again, I don't think this is a proton bug, but rather mono, because I get this as well with the native linux version and latest Recall/MM/KSPApiExtension:

[EXC 14:11:08.302] Exception: Magic number is wrong: 542 System.TermInfoReader.ReadHeader (System.Byte[] buffer, System.Int32& position) (at <9577ac7a62ef43179789031239ba8798>:0) System.TermInfoReader..ctor (System.String term, System.String filename) (at <9577ac7a62ef43179789031239ba8798>:0) System.TermInfoDriver..ctor (System.String term) (at <9577ac7a62ef43179789031239ba8798>:0) System.ConsoleDriver.CreateTermInfoDriver (System.String term) (at <9577ac7a62ef43179789031239ba8798>:0) System.ConsoleDriver..cctor () (at

Geez!!! This one is a new! (googling, googling, googling… ah! found something!)

Try to set the following environment variable before running KSP:

export TERM=xterm

(change xterm to any other terminal you are using on your rig - xterm is a safe default value, nobody uses it but it's always available)

I think this is more a mishap no your .profile file (or perhaps the program launcher you are using) than anything else!

hendrack commented 2 years ago

Never had this issue with a lot of linux flavors in the past, but that environment variable did the trick.

Lisias commented 2 years ago

@hendrack

Never had this issue with a lot of linux flavors in the past, but that environment variable did the trick.

Put that line in your ~./profile file. This will fix the problem for everybody.

I think current maintainers are not used to the old X11 ways - and since even WayLand aims to be support X11 applications (Xwayland), this may be a mistake.

Lisias commented 2 years ago

Well, case closed! :)