msgpack / msgpack-cli

MessagePack implementation for Common Language Infrastructure / msgpack.org[C#]
http://msgpack.org
Apache License 2.0
835 stars 175 forks source link

System.TypeLoadException in Unity #319

Open teremyx opened 5 years ago

teremyx commented 5 years ago

Hi. I'm using MessagePack in Unity (not using IL2CPP) and also in a standalone c# application (a master server, that sends and receives objects from the (Unity-)client).

Somehow I get this error when trying to serialize an object of class "ClientSetupRequest": System.TypeLoadException: Could not load type 'MessagePack.Formatters.ClientSetupRequestFormatter1' from assembly ''. at MessagePack.FormatterResolverExtensions.GetFormatterWithVerify[T] (MessagePack.IFormatterResolver resolver) [0x0001b] in <9584f10ef1c54d659bd9587a0a564bad>:0 at MessagePack.MessagePackSerializer.Serialize[T] (T obj, MessagePack.IFormatterResolver resolver) [0x0000a] in <9584f10ef1c54d659bd9587a0a564bad>:0 at MessagePack.MessagePackSerializer.Serialize[T] (T obj) [0x00000] in <9584f10ef1c54d659bd9587a0a564bad>:0 at (wrapper dynamic-method) System.Object.lambda_method(System.Runtime.CompilerServices.Closure,object) at MessagePack.MessagePackSerializer+NonGeneric.Serialize (System.Type type, System.Object obj) [0x00006] in <9584f10ef1c54d659bd9587a0a564bad>:0 at...

The ClientSetupRequest class looks like this: `using MessagePack;

[MessagePackObject] public class ClientSetupRequest : GameNetworkEvent {

[Key(0)]
public string PlayerName;

} `

The GameNetworkEvent class is just an empty class.

I'm not sure but I think something the exception doesn't occur for some reason...

What's strange is that it says:

from assembly ''.

So the assembly is empty?

I don't know which version I was using before, but I just redownloaded MessagePack (version 1.7.3.4 using nuget) and copied the .dll from the net47 folder to my Unity Project and also referencing it from my standalone c# app.