我刚刚在 OSX 上安装了 xamarin 和 monogame 我试图运行一个在 Windows 上完美运行的非常基本的演示项目。但我收到以下错误:
System.NullReferenceException: Object reference not set to an instance of an object
at Microsoft.Xna.Framework.OpenTKGameWindow.Initialize () [0x00000] in <filename unknown>:0
at Microsoft.Xna.Framework.OpenTKGameWindow..ctor () [0x00000] in <filename unknown>:0
at Microsoft.Xna.Framework.OpenTKGamePlatform..ctor (Microsoft.Xna.Framework.Game game) [0x00000] in <filename unknown>:0
at Microsoft.Xna.Framework.GamePlatform.Create (Microsoft.Xna.Framework.Game game) [0x00000] in <filename unknown>:0
at Microsoft.Xna.Framework.Game..ctor () [0x00000] in <filename unknown>:0
at test.Game1..ctor () [0x00057] in /Users/remojansen/Desktop/test/test/Game1.cs:37
at test.Program.Main () [0x00001] in /Users/remojansen/Desktop/test/test/Program.cs:19
代码没有任何问题,所以我一定是缺少一个 DLL 什么的?您对可能缺少的内容有任何想法吗?
谢谢 :)
[编辑]
反汇编在第二行显示错误:
00000155 callvirt IWindowInfo OpenTK.NativeWindow:get_WindowInfo ()
0000015a ldnull
0000015b callvirt Object System.Reflection.PropertyInfo:GetValue (Object, Object[])
00000160 unbox.any System.IntPtr
00000165 stfld
0000016a call GraphicsMode OpenTK.Graphics.GraphicsMode:get_Default ()
0000016f ldarg.0
00000170 ldfld
00000175 callvirt IWindowInfo OpenTK.NativeWindow:get_WindowInfo ()
0000017a newobj Void OpenTK.Graphics.GraphicsContext:.ctor (GraphicsMode, IWindowInfo)
我还手动编译了 OpenTK,当我运行示例时,它们似乎工作正常:
我想问题出在monogame中,我使用xamarin monogame项目模板安装了monogame。