prime31 / Nez

Nez is a free 2D focused framework that works with MonoGame and FNA
MIT License
1.76k stars 355 forks source link

Crash when toggling imGui on Linux #730

Open puthre opened 1 year ago

puthre commented 1 year ago

Whenever I want to toggle imgui from the console nez crashes with

Unhandled Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.BadImageFormatException: Expected reference type but got type kind 17
  at Nez.ImGuiTools.ImGuiRenderer..ctor (Microsoft.Xna.Framework.Game game) [0x000c2] in <83e79ee4af4244008472303bbc7ef68d>:0 
  at Nez.ImGuiTools.ImGuiManager..ctor (Nez.ImGuiTools.ImGuiOptions options) [0x000de] in <83e79ee4af4244008472303bbc7ef68d>:0 
  at Nez.ImGuiTools.ImGuiManager.ToggleImGui () [0x00010] in <83e79ee4af4244008472303bbc7ef68d>:0 
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <a17fa1457c5d44f2885ac746c1764ea5>:0 
   --- End of inner exception stack trace ---
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00083] in <a17fa1457c5d44f2885ac746c1764ea5>:0 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <a17fa1457c5d44f2885ac746c1764ea5>:0 
  at Nez.Console.DebugConsole+<>c__DisplayClass49_1.<ProcessMethod>b__0 (System.String[] args) [0x00010] in <f9909f6bac3340238b24ce00b15e914e>:0 
  at Nez.Console.DebugConsole.ExecuteCommand (System.String command, System.String[] args) [0x0001d] in <f9909f6bac3340238b24ce00b15e914e>:0 
  at Nez.Console.DebugConsole.EnterCommand () [0x000cc] in <f9909f6bac3340238b24ce00b15e914e>:0 
  at Nez.Console.DebugConsole.HandleKey (Microsoft.Xna.Framework.Input.Keys key) [0x00991] in <f9909f6bac3340238b24ce00b15e914e>:0 
  at Nez.Console.DebugConsole.UpdateOpen () [0x000fb] in <f9909f6bac3340238b24ce00b15e914e>:0 
  at Nez.Console.DebugConsole.Update () [0x0000b] in <f9909f6bac3340238b24ce00b15e914e>:0 
  at Nez.Core.EndDebugUpdate () [0x00001] in <f9909f6bac3340238b24ce00b15e914e>:0 
  at Nez.Core.Update (Microsoft.Xna.Framework.GameTime gameTime) [0x00163] in <f9909f6bac3340238b24ce00b15e914e>:0 
  at Microsoft.Xna.Framework.Game.DoUpdate (Microsoft.Xna.Framework.GameTime gameTime) [0x00019] in <8f3f3a1b6ac843848b40be60a3b6f853>:0 
  at Microsoft.Xna.Framework.Game.Tick () [0x0021c] in <8f3f3a1b6ac843848b40be60a3b6f853>:0 
  at Microsoft.Xna.Framework.SdlGamePlatform.RunLoop () [0x00021] in <8f3f3a1b6ac843848b40be60a3b6f853>:0 
  at Microsoft.Xna.Framework.Game.Run (Microsoft.Xna.Framework.GameRunBehavior runBehavior) [0x00082] in <8f3f3a1b6ac843848b40be60a3b6f853>:0 
  at Microsoft.Xna.Framework.Game.Run () [0x0000c] in <8f3f3a1b6ac843848b40be60a3b6f853>:0 
  at TheMoonLeverageClient.Program.Main () [0x00007] in <dffa7c54543e41b4b5b359e3d6062ee7>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.BadImageFormatException: Expected reference type but got type kind 17
  at Nez.ImGuiTools.ImGuiRenderer..ctor (Microsoft.Xna.Framework.Game game) [0x000c2] in <83e79ee4af4244008472303bbc7ef68d>:0 
  at Nez.ImGuiTools.ImGuiManager..ctor (Nez.ImGuiTools.ImGuiOptions options) [0x000de] in <83e79ee4af4244008472303bbc7ef68d>:0 
  at Nez.ImGuiTools.ImGuiManager.ToggleImGui () [0x00010] in <83e79ee4af4244008472303bbc7ef68d>:0 
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <a17fa1457c5d44f2885ac746c1764ea5>:0 
   --- End of inner exception stack trace ---
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00083] in <a17fa1457c5d44f2885ac746c1764ea5>:0 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <a17fa1457c5d44f2885ac746c1764ea5>:0 
  at Nez.Console.DebugConsole+<>c__DisplayClass49_1.<ProcessMethod>b__0 (System.String[] args) [0x00010] in <f9909f6bac3340238b24ce00b15e914e>:0 
  at Nez.Console.DebugConsole.ExecuteCommand (System.String command, System.String[] args) [0x0001d] in <f9909f6bac3340238b24ce00b15e914e>:0 
  at Nez.Console.DebugConsole.EnterCommand () [0x000cc] in <f9909f6bac3340238b24ce00b15e914e>:0 
  at Nez.Console.DebugConsole.HandleKey (Microsoft.Xna.Framework.Input.Keys key) [0x00991] in <f9909f6bac3340238b24ce00b15e914e>:0 
  at Nez.Console.DebugConsole.UpdateOpen () [0x000fb] in <f9909f6bac3340238b24ce00b15e914e>:0 
  at Nez.Console.DebugConsole.Update () [0x0000b] in <f9909f6bac3340238b24ce00b15e914e>:0 
  at Nez.Core.EndDebugUpdate () [0x00001] in <f9909f6bac3340238b24ce00b15e914e>:0 
  at Nez.Core.Update (Microsoft.Xna.Framework.GameTime gameTime) [0x00163] in <f9909f6bac3340238b24ce00b15e914e>:0 
  at Microsoft.Xna.Framework.Game.DoUpdate (Microsoft.Xna.Framework.GameTime gameTime) [0x00019] in <8f3f3a1b6ac843848b40be60a3b6f853>:0 
  at Microsoft.Xna.Framework.Game.Tick () [0x0021c] in <8f3f3a1b6ac843848b40be60a3b6f853>:0 
  at Microsoft.Xna.Framework.SdlGamePlatform.RunLoop () [0x00021] in <8f3f3a1b6ac843848b40be60a3b6f853>:0 
  at Microsoft.Xna.Framework.Game.Run (Microsoft.Xna.Framework.GameRunBehavior runBehavior) [0x00082] in <8f3f3a1b6ac843848b40be60a3b6f853>:0 
  at Microsoft.Xna.Framework.Game.Run () [0x0000c] in <8f3f3a1b6ac843848b40be60a3b6f853>:0 
  at TheMoonLeverageClient.Program.Main () [0x00007] in <dffa7c54543e41b4b5b359e3d6062ee7>:0 

I'm using Ubuntu 20.04.4 LTS

puthre commented 1 year ago

Works fine when using Nez.MG38.csproj and MG38.ImGui.csproj which I assume uses monogame 3.8 instead of 3.7.1. Not sure why default is 3.7.1 and if there are any issues with 3.8.