I've been trying to get 3rd party dlls to load with the api but it's not working, I'ved added them to the mange folder and still a no go, Someone said I need to do an assembly load but I'm not to sure how to do that. I'm wanting to use newtonsoft so i can write data to a json and show it on a website.
While not having done a mod for this, I vaguely remember a note about only a single assembly being supported. So, additional assemblies will have to be merged into a single assembly if that is the case using an appropriate tool.
I think i'm getting close. But I get this Code: 11-15:24:23.587 10_24 -EXC- System.MissingMethodException: Default constructor not found for type Newtonsoft.Json.JsonConvert at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) [0x0007b] in <567df3e0919241ba98db88bec4c6696f>:0 at System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00009] in <567df3e0919241ba98db88bec4c6696f>:0 at System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00027] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00020] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Activator.CreateInstance (System.Type type) [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0 at ServerStatus.Json.LoadNewtonSoftAssemby () [0x00087] in <37fa2ebd1cf44fbc9da29fa7d82cd2a0>:0 at ServerStatus.ServerInfo.Game_Start (Eleon.Modding.ModGameAPI dediAPI) [0x0003f] in <37fa2ebd1cf44fbc9da29fa7d82cd2a0>:0 at ModManager.Order (Eleon.Modding.ModGameAPI ) [0x00026] in <0ce5631c6d164269905ad1d036b92ecd>:0 I know a little csharp but I haven't figured out all the names, I'm a self taught programmer, just say I know enough to do Harmony Patching. Got a few mods on nexus for a different game. Code: public static void LoadNewtonSoftAssemby() { Assembly a = Assembly.Load("Newtonsoft.Json"); Type myType = a.GetType("Newtonsoft.Json.JsonConvert"); MethodInfo myMethod = myType.GetMethod("SerializeObject", new Type[] { typeof(String) }); //error is here object obj = Activator.CreateInstance(myType); //--------- myMethod.Invoke(obj, null); } What i'm trying to do is get DediStats and PlayerInfo and put them in a Json file so I can show the data on a website. I got the DediStats Part working since I didn't need to use any list. PlayerInfo Data works but I'm trying to make a list for each player so JsonUtlity wasn't my best for that and I already have working code on newtonsoft for a list system. https://github.com/ihatetn931/Subna...ubnauticaBelowzeroMods/SubnauticaBZRP/json.cs
If I remember correctly, JsonConvert is a static class and therefore has no constructors, so you cant create an instance of it. The specific error means the method you are trying to invoke does not exist (ie a default constructor does not exist). You only need to invoke the method without an instance - ie myMethod.Invoke(null, <your parameters>). null because there is no instance.
You can use Newtonsoft directly and with the YAML files for mods you NO longer need to put everything in a single DLL - you only have to copy the missing DLL for serialization - see here the "CopyMissingDlls" method in the source https://github.com/GitHub-TC/Empyri...ster/EmpyrionNetAPIModBase/EmpyrionModBase.cs at line 155
That worked, thanks appreciate it. Was much easier to get it working then I thought. This might be off topic but is there any documentation any where for the IModApi? I've only been able to find the legacy documentation.