LemonUIbyLemon / LemonUI

LemonUI for .NET (FiveM, RageMP, RagePluginHook and ScriptHookVDotNet 3)
MIT License
177 stars 40 forks source link

MissingMethodException when returning NativeMenu.Name or NativeMenu.BannerText #128

Closed dppls closed 1 year ago

dppls commented 1 year ago

Hey, I'm always getting a MissingMethodException when trying to return a NativeMenu's Name or BannerText.

The code throwing the exception looks like this (I've already reduced it to the bare minimum, to determine what was causing the exception)

NativeMenu mainmenu = new NativeMenu("EcoPloos", "Main Menu");  // is added to ObjectPool on CreateMenu()
public string ReturnActiveMenu() {  // function is called when OnKeyDown Keys.Enter
   int cnt = 0;
   string activeMenuName = "404";

   try {
      activeMenuName = mainmenu.Name;  // removing this line is fixing the exception, same behaviour with mainmenu.BannerText
      Notification.Show($"You're at {activeMenuName} ({cnt})");
   } catch (Exception ex) {
      Notification.Show("Oopsie :/ \n\n" + ex.Message);
   }
   return activeMenuName;
}

The script throws the MissingMethodException but it's being catched outside of my try-catch, notice the Notification looking different to what I declared: grafik

Same behaviour when calling BannerText but Description works fine.

Any help is very much appreciated - I'm just trying to figure out, where in the menu or submenus the player actually is.

justalemon commented 1 year ago

What does your stack trace says?

dppls commented 1 year ago

I have no idea how to look at the stack trace when gta is not actually crashing - sorry, I started scripting just a few days ago

justalemon commented 1 year ago

Check the file called ScriptHookVDotNet.log in your game folder.

dppls commented 1 year ago

Got it, thank you.

[17:50:36] [ERROR] Caught unhandled exception: System.MissingMethodException: Method not found: 'System.String LemonUI.Menus.NativeMenu.get_Name()'. at ecoploos.Main.ReturnActiveMenu() at ecoploos.Main.OnKeyDown(Object sender, KeyEventArgs e) in C:\Users\dppls\source\repos\ecoploos\Main.cs:line 230 at SHVDN.Script.DoTick() [17:50:36] [ERROR] The exception was thrown while executing the script ecoploos.Main.

justalemon commented 1 year ago

You have an outdated version of LemonUI. You are using in your Visual Studio/Rider project version 1.10 but your GTA V folder has 1.9.4 or older.

dppls commented 1 year ago

that's it, I had to manually change the lemonui version in NuGet to 1.9.4.

Working now, thank you so much!