My WebGL build stopped working after I broke out some code into libraries

I used to have all my C# code in the Unity directory itself, but I decided to break out the logic parts into a standalone library (since it is also going to be run on a server eventually). I also added some external libraries (Newtonsoft.json and Randomizer.NET). I’ve configured the library to build with C# 9.0 and .NET framework 471, and this doesn’t give me any errors in Unity when I transfer the built DLL files there.

When I play my game in Unity, it works fine. But when I make a WebGL build, deploy it to itch.io and run it there, the game breaks immediately, and in the chrome console, I see this:

PlatformNotSupportedException: Operation is not supported on this platform.
at System.Reflection.Emit.DynamicMethod..ctor (System.String name, System.Type returnType, System.Type[ ] parameterTypes, System.Type owner, System.Boolean skipVisibility) [0x00000] in <00000000000000000000000000000000>:0

I am fairly new to C# development and don’t fully understand what versions of .NET and C# work with Unity etc. But I’m running the latest version of Unity.

Anyone able to help me? Thanks in advance!

I had this very same problem, related to the deserialization of JSON with Newtonsoft.json.
I solved it by removing the Newtonsoft.json package and replacing it with the JsonUtility that’s implemented in the UnityEngine.JSONSerializeModule module.