TL;DR for Devs
The crash occurs in KMod.DLLLoader.LoadDLLs() on a call to Assembly.GetTypes(), it can be resolved by adding a try/catch around the call to GetTypes.
Issue Description
Including some dependencies with a mod can lead to failure. For example, adding the massive Jering.Javascript.NodeJS or other large frameworks and including all the dependency DLLs with the mod will trigger the following exception (and trigger the crash dialog).
Exception while loading mod ClusterioBridge at C:/Users/heine/Documents/Klei/OxygenNotIncluded/mods/Dev/ClusterioBridge. System.Reflection.ReflectionTypeLoadException: Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown. at (wrapper managed-to-native) System.Reflection.Assembly.GetTypes(System.Reflection.Assembly,bool) at System.Reflection.Assembly.GetTypes () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0 at KMod.DLLLoader.LoadDLLs (KMod.Mod ownerMod, System.String harmonyId, System.String path, System.Boolean isDev) [0x0010c] in <b2059d57da244ebc9fb8d55e7bbaa6c7>:0 at UnityEngine.Debug.LogError (System.Object message, UnityEngine.Object context) [0x00000] in <72b60a3dd8cd4f12a155b761a1af9144>:0 at Debug.LogError (System.Object obj, UnityEngine.Object context) [0x00000] in <3366109ff608488f8317d0b43357f1ba>:0 at DebugUtil.LogErrorArgs (UnityEngine.Object context, System.Object[] objs) [0x00000] in <3366109ff608488f8317d0b43357f1ba>:0 at DebugUtil.LogException (UnityEngine.Object context, System.String errorMessage, System.Exception e) [0x00000] in <3366109ff608488f8317d0b43357f1ba>:0 at KMod.DLLLoader.LoadDLLs (KMod.Mod ownerMod, System.String harmonyId, System.String path, System.Boolean isDev) [0x00000] in <b2059d57da244ebc9fb8d55e7bbaa6c7>:0 at KMod.Mod.Load (KMod.Content content) [0x00000] in <b2059d57da244ebc9fb8d55e7bbaa6c7>:0 at KMod.Manager.Load (KMod.Content content) [0x00000] in <b2059d57da244ebc9fb8d55e7bbaa6c7>:0 at Global.Awake () [0x00000] in <b2059d57da244ebc9fb8d55e7bbaa6c7>:0 at UnityEngine.Object.Internal_InstantiateSingleWithParent_Injected (UnityEngine.Object data, UnityEngine.Transform parent, UnityEngine.Vector3& pos, UnityEngine.Quaternion& rot) [0x00000] in <72b60a3dd8cd4f12a155b761a1af9144>:0 at UnityEngine.Object.Internal_InstantiateSingleWithParent (UnityEngine.Object data, UnityEngine.Transform parent, UnityEngine.Vector3 pos, UnityEngine.Quaternion rot) [0x00000] in <72b60a3dd8cd4f12a155b761a1af9144>:0 at UnityEngine.Object.Instantiate (UnityEngine.Object original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation, UnityEngine.Transform parent) [0x00000] in <72b60a3dd8cd4f12a155b761a1af9144>:0 at UnityEngine.Object.Instantiate[T] (T original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation, UnityEngine.Transform parent) [0x00000] in <72b60a3dd8cd4f12a155b761a1af9144>:0 at Util.KInstantiate (UnityEngine.GameObject original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation, UnityEngine.GameObject parent, System.String name, System.Boolean initialize_id, System.Int32 gameLayer) [0x00000] in <3366109ff608488f8317d0b43357f1ba>:0 at Util.KInstantiate (UnityEngine.GameObject original, UnityEngine.GameObject parent, System.String name) [0x00000] in <3366109ff608488f8317d0b43357f1ba>:0 at LaunchInitializer.Update () [0x00000] in <b2059d57da244ebc9fb8d55e7bbaa6c7>:0 Build: U42-509629-SD
I have worked around the issue by creating a separate mod to patch the ONI code before loading the larger mod.
Steps to Reproduce
- Develop a mod.
- Add some nuget dependencies (i.e. any large framework or package with lots of dependencies).
- Reference those packages in your mod and compile it.
- Try to load your mod with its new behemoth dependencies.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now