D_Pain

Newtonsoft Error Rimworld

Jul 23rd, 2021 (edited)
955
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using Newtonsoft.Json;
  3. using RimWorld;
  4. using Verse;
  5.  
  6.  
  7. namespace my_new_mod {
  8.     [StaticConstructorOnStartup]
  9.     public static class Main {
  10.         /**
  11.          * Constructor
  12.          */
  13.         static Main() {
  14.             // Outputs "Hello World!" to the dev console.
  15.             Log.Message("Hello World!");
  16.             string[] arr = new string[] { "Small", "Medium", "Large" };
  17.  
  18.             Type t = typeof(JsonConvert);
  19.             Log.Message(t.ToString()); // Returns "Newtonsoft.Json.JsonConvert"
  20.             Log.Message(JsonConvert.Undefined); // Returns "undefined"
  21.  
  22.             string json = JsonConvert.SerializeObject(arr, Formatting.Indented);
  23.             Log.Message(json);
  24.             /**
  25.             Error in static constructor of Rim_my_new_mod.Main: System.TypeInitializationException: The type initializer for 'Rim_my_new_mod.Main' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Newtonsoft.Json.JsonWriter' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Newtonsoft.Json.Utilities.ConvertUtils' threw an exception. ---> System.TypeLoadException: Could not resolve type with token 01000024 (from typeref, class/assembly System.Numerics.BigInteger, System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
  26.    --- End of inner exception stack trace ---
  27.   at Newtonsoft.Json.Utilities.EnumUtils.ToUInt64 (System.Object value) [0x00006] in <f74995119334484fb6db6825be2eac0d>:0
  28.   at Newtonsoft.Json.Utilities.EnumUtils.InitializeValuesAndNames (Newtonsoft.Json.Utilities.StructMultiKey`2[T1,T2] key) [0x00045] in <f74995119334484fb6db6825be2eac0d>:0
  29.   at (wrapper delegate-invoke) System.Func`2[Newtonsoft.Json.Utilities.StructMultiKey`2[System.Type,Newtonsoft.Json.Serialization.NamingStrategy],Newtonsoft.Json.Utilities.EnumInfo].invoke_TResult_T(Newtonsoft.Json.Utilities.StructMultiKey`2<System.Type, Newtonsoft.Json.Serialization.NamingStrategy>)
  30.   at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00034] in <eae584ce26bc40229c1b1aa476bfa589>:0
  31.   at Newtonsoft.Json.Utilities.ThreadSafeStore`2[TKey,TValue].Get (TKey key) [0x00000] in <f74995119334484fb6db6825be2eac0d>:0
  32.   at Newtonsoft.Json.Utilities.EnumUtils.GetEnumValuesAndNames (System.Type enumType) [0x0000c] in <f74995119334484fb6db6825be2eac0d>:0
  33.   at Newtonsoft.Json.JsonWriter.BuildStateArray () [0x0001b] in <f74995119334484fb6db6825be2eac0d>:0
  34.   at Newtonsoft.Json.JsonWriter..cctor () [0x000b3] in <f74995119334484fb6db6825be2eac0d>:0
  35.    --- End of inner exception stack trace ---
  36.   at Newtonsoft.Json.JsonTextWriter..ctor (System.IO.TextWriter textWriter) [0x00000] in <f74995119334484fb6db6825be2eac0d>:0
  37.   at Newtonsoft.Json.JsonConvert.SerializeObjectInternal (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializer jsonSerializer) [0x00015] in <f74995119334484fb6db6825be2eac0d>:0
  38.   at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, System.Type type, Newtonsoft.Json.Formatting formatting, Newtonsoft.Json.JsonSerializerSettings settings) [0x0000e] in <f74995119334484fb6db6825be2eac0d>:0
  39.   at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, Newtonsoft.Json.Formatting formatting, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <f74995119334484fb6db6825be2eac0d>:0
  40.   at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, Newtonsoft.Json.Formatting formatting) [0x00000] in <f74995119334484fb6db6825be2eac0d>:0
  41.   at Rim_my_new_mod.Main..cctor () [0x0004d] in <554e655008644f43a47c5a6b2203e83e>:0
  42.    --- End of inner exception stack trace ---
  43.   at (wrapper managed-to-native) System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(intptr)
  44.   at System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor (System.RuntimeTypeHandle type) [0x0002a] in <eae584ce26bc40229c1b1aa476bfa589>:0
  45.   at Verse.StaticConstructorOnStartupUtility.CallAll () [0x0001a] in <842a7a129d554204bf93f11a26f1d770>:0
  46. UnityEngine.StackTraceUtility:ExtractStackTrace ()
  47. Verse.Log:Error (string)
  48. Verse.StaticConstructorOnStartupUtility:CallAll ()
  49. Verse.PlayDataLoader/<>c:<DoPlayLoad>b__4_3 ()
  50. Verse.LongEventHandler:ExecuteToExecuteWhenFinished ()
  51. Verse.LongEventHandler:UpdateCurrentAsynchronousEvent ()
  52. Verse.LongEventHandler:LongEventsUpdate (bool&)
  53. (wrapper dynamic-method) Verse.Root:Verse.Root.Update_Patch1 (Verse.Root)
  54. Verse.Root_Entry:Update ()
  55.             */
  56.         }
  57.     }
  58. }
RAW Paste Data