Search code examples
unity-game-enginesocket.iounity-webgl

Error in Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35


I am trying to deploy a unity game to webgl. Everything works fine on windows. I am using socketio in Unity for my multiplayer game, I'm not sure if that's relevant. Also, I am using unity 2020 and I already disabled compression. I get this error in the console in chrome:

{"tid":1,"div":"EventDescriptor","msg":"Call","ex": [{"msg": "System.Reflection.Emit.DynamicMethod::.ctor", "stack": ""}],"stack":"","ctxs":[],"t":637425122207370000,"ll":"Exception","bh":1} (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

I don't know what that error means. Can anyone help?


Solution

  • This error is because the compiler for Web does not recognize a method.

    In your case, it's System.Reflection.Emit.DynamicMethod.

    Explanation:

    WebGL on Unity is AOT (Ahead of time) compiled and a method that uses reflection might not work. And it seems like you tried to use namespace Emit which is completely forbidden on AOT platforms including Web.

    You need to remove or replace all reflection (especially Emit) with something that is able to compile Ahead of time!

    If you did not use Emit or you don't know where it might come from, you should give us a full error message. PlayerSettings -> EnableExceptions -> Full With Stacktrace