Search Unity

"TargetParameterCountException: parameters do not match signature". Okay, which function?

Discussion in 'Editor & General Support' started by MrDude, Sep 27, 2018.

  1. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Hi there

    I started seeing this error pop up all of a sudden and have no idea what is causing it or how to figure that out.
    How can I determine the cause of this and get it to stop?
    Thanks

    Code (csharp):
    1. TargetParameterCountException: Number of parameters specified does not match the expected number.
    2. System.Reflection.MonoMethod.ConvertValues (System.Reflection.Binder binder, System.Object[] args, System.Reflection.ParameterInfo[] pinfo, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) (at <f2e6809acb14476a81f399aeb800f8f2>:0)
    3. System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <f2e6809acb14476a81f399aeb800f8f2>:0)
    4. System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <f2e6809acb14476a81f399aeb800f8f2>:0)
    5. UnityEditor.EditorAssemblies.ProcessInitializeOnLoadMethod (System.Reflection.MethodInfo method) (at C:/buildslave/unity/build/Editor/Mono/EditorAssemblies.cs:116)
    6. UnityEditor.EditorAssemblies.ProcessInitializeOnLoadAttributes () (at C:/buildslave/unity/build/Editor/Mono/EditorAssemblies.cs:135)
    7.  
    EDIT: SOLVED:
    Of course, after ages of wondering about it I discover the answer myself only a minute after finally posting the question here... Sigh... Facepalm.

    Turns out I was using the ProcessInitializeOnLoadMethod directive on a function and later changed the function to require a parameter. Voila. Instant problem created. The fix just required a simple //
    :) Sorry for wasting your time!
     
    Last edited: Sep 27, 2018
  2. FM-Productions

    FM-Productions

    Joined:
    May 1, 2017
    Posts:
    72
    Had the same issue with a different method. I put a method called "ShowButton" in a class that inherits from EditorWindow. Looks like Unity looks for a method with that name through reflection, so implementing a custom method with that name should be avoided. I only found out about that through trial and error as the error message wasn't really helpful regarding which method was actually the cause.