Search Unity

“Non-static method requires a target” exception after Unity upgrade

Discussion in 'Editor & General Support' started by iDosGames, Aug 24, 2021.

  1. iDosGames

    iDosGames

    Joined:
    Jan 7, 2020
    Posts:
    1
    After upgrading Unity from 2020.3.13f to 2020.3.16f1, I get this exception when I hit play in the editor or open a scene:

    "System.Reflection.TargetException: Non-static method requires a target."

    At a C# level, I understand the meaning of that error. If the problem were in my code, I could fix it pretty simply.

    But figuring out which thing in Unity or 3rd-party assets needs to be fixed... huh. I don't know.

    The call stack on the error seems pretty generic:

    System.Reflection.TargetException: Non-static method requires a target.
    at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0004c] in <695d1cc93cca45069c528c15c9fdd749>:0
    at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0
    at UnityEditor.EditorAssemblies.ProcessInitializeOnLoadMethodAttributes () [0x00047] in /Users/bokken/buildslave/unity/build/Editor/Mono/EditorAssemblies.cs:154
    UnityEditor.EditorAssemblies:processInitializeOnLoadMethodAttributes () (at /Users/bokken/buildslave/unity/build/Editor/Mono/EditorAssemblies.cs:158)

    I put the game in release and immediately got more than 200 crashes, although before that there was not a single crash.

    How to fix this? Or even troubleshoot it?
     
  2. Felshatner

    Felshatner

    Joined:
    Jul 3, 2021
    Posts:
    1
    I've got the same error but haven't had much trouble with my game-in-progress crashing (the crashes thus far are the result of bugs in my code, not this). Rather unhelpful error message that seems to be something buried in Unity code rather than anything we added. Given the lack of responses here I suspect no one knows the solution or not many people have run into it.
     
  3. jdempsey87

    jdempsey87

    Joined:
    Apr 4, 2016
    Posts:
    2


    Did you ever get to the bottom of this, I just ran into the same issue.