Search Unity

Bug MissingMethodException in class constructor

Discussion in 'Editor & General Support' started by Danil_Chizhikov, May 25, 2023.

  1. Danil_Chizhikov

    Danil_Chizhikov

    Joined:
    Jul 21, 2018
    Posts:
    5
    After updating my Unity project from version 2021.3.12f1 to 2022.2.20f1, I encountered an error when attempting to instantiate the `PerformanceManager` class using `Activator.CreateInstance()`. The console output reports the following error: "MissingMethodException: Constructor on type
    'PerformanceAnalytics.PerformanceManager' not found."
    It's worth noting that the `PerformanceManager` class was installed as a separate package via npm, and I've confirmed that the constructor is public and accepts the correct arguments.
    I've tried recompiling my code and updating to the latest version of Unity, but the error continues to occur.
    Please let me know if there are any additional steps I can take to resolve this issue or any more information I can provide to help diagnose the problem.
    Thank you for your assistance.
     
  2. Danil_Chizhikov

    Danil_Chizhikov

    Joined:
    Jul 21, 2018
    Posts:
    5
    More info.
    Logs:
    MissingMethodException: Constructor on type 'PerformanceAnalytics.PerformanceManager' not found.
    at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0
    at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x00000] in <00000000000000000000000000000000>:0
     

    Attached Files:

  3. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,819
    Is this your own code or Unity's code?

    If your own, you could try Type.GetConstructor? It's more performance than
    System.Activator
    too.
     
  4. Danil_Chizhikov

    Danil_Chizhikov

    Joined:
    Jul 21, 2018
    Posts:
    5
    It is my code, but it worked on Unity 2021.3.12f1 and stopped work in Unity 2022.2.20f1 and if do downgrade Unity version it doesn't work again
     
  5. Danil_Chizhikov

    Danil_Chizhikov

    Joined:
    Jul 21, 2018
    Posts:
    5
    I resolved the issue by rolling back to a working build version in git, preserving the ProjectSettings and Packages folders. After that, I went back to the commit where the problem arose, replaced the folders with the ones I had saved, and deleted the Library folder. After doing this, the issue was resolved. It seems that there was some kind of issue with the Unity versions or Unity packages.