Vanilla-Expanded / VanillaExpandedFramework

Vanilla Expanded Framework for RimWorld
Other
74 stars 37 forks source link

Error in static constructor of KCSG.StartupActions #49

Closed TeflonJim closed 1 year ago

TeflonJim commented 1 year ago

I'm trying to track down the cause of the exception below:

Error in static constructor of KCSG.StartupActions: System.TypeInitializationException: The type initializer for 'KCSG.StartupActions' threw an exception. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: key
  at System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key) [0x00008] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].ContainsKey (TKey key) [0x00000] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at KCSG.StartupActions.AddToMissing (System.String modName, System.String symbol) [0x00001] in <966b585d4ec6409889b4eff92bf06801>:0 
  at KCSG.StructureLayoutDef.ResolveSymbols () [0x00107] in <966b585d4ec6409889b4eff92bf06801>:0 
  at KCSG.StructureLayoutDef.ResolveLayouts () [0x0005c] in <966b585d4ec6409889b4eff92bf06801>:0 
  at KCSG.StartupActions..cctor () [0x00082] in <966b585d4ec6409889b4eff92bf06801>:0 
   --- End of inner exception stack trace ---
  at (wrapper managed-to-native) System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(intptr)
  at System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor (System.RuntimeTypeHandle type) [0x0002a] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at (wrapper dynamic-method) Verse.StaticConstructorOnStartupUtility.Verse.StaticConstructorOnStartupUtility.CallAll_Patch2() 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Which ultimately takes me as far as the null conditional linked below allowing a null string through to AddMissing which throws on ContainsKey on Dictionary<string,...:

https://github.com/Vanilla-Expanded/VanillaExpandedFramework/blob/b95970be6134c5db2157b8779e8e4f79018998cd/Source/KCSG/Defs/StructureLayoutDef.cs#LL185C1-L185C48

What does failure of this method impact?

In the meantime smashing my mod list :)

KylianB commented 1 year ago

The issue is caused by a mod name being null, this never happened to me before. Could you share a full hugslib log? The error shouldn't have any consequences on the generation. I will add a null check on the mod name if it proves necessary.

TeflonJim commented 1 year ago

Sure!

https://gist.github.com/HugsLibRecordKeeper/d2ee0153a2b2497dd26920232fdb8b88

If I evict Vanilla Outposts Expanded from this list the problem goes away.

I'm not particularly suggesting this is where the problem lies, but you can see the mod list is not small and just the loading time makes debugging, without being able to get some identifying information, an extremely time consuming exercise.

Just to be clear, I am not expecting any one but me to debug my mod list. I expect this to be a compound error rather than a straight "if I have the framework module and outposts, then I get this error". This is why I looked at the source code for the library, following the stack trace, rather than just posting the raw exception :)

KylianB commented 1 year ago

Added null check in ba626a3. Closing.