calling Encoding.UTF8.GetBytes(JSON) in a dll causes exception, while in src format everything works great.

This is so weird, I can’t even explain it.

I’ve created an application to add some functionality to my unity game.
Everything works fine when I ran the same steps from unity.
The steps:

  1. Create a class.
  2. Convert it to JSON. (Using Newtonsoft.Json package)
  3. Add the converted class to another class as a member.
  4. convert that class to JSON as well
  5. run Encoding.UTF8.GetBNytes(json)

It works great when I copy the source files and run them via unity(in the editor), but every time I build it alone and add the DLL, unity raises an exception at the Byte convert stage (I know this because I have tried commenting out every part of the code, and that’s the only part that’s failing)

This is the error -

TypeLoadException: Could not resolve type with token 01000019 (from typeref, class/assembly System.Text.Encoding, System.Runtime, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
Client.CreatePlayer (System.String client, System.String id, System.String type, System.String teamId, System.Single[] location) (at <59a6b6b960504910bd482e9be83660f7>:0)
PlayerController.Start () (at Assets/Scripts/PlayerController.cs:21)

I’ve tried switching to ASCII but it still failed.
What should I do? :frowning:

I am also having this problem. Did you find a solution?,I’m also having this problem. Did you find a solution?

Not yet. But since it’s only for testing my multiplayer msgs, I’ve used the source of my code, and when I’m closer to production - I’m gonna transfer without JSON but with another serializer(JSON is not efficient and only for testing) so it should be good.

BTW, my guess is that there is something wrong with the runtime, but I’m not sure.