Can't run basic MonoGame OpenGL project (in Xamarin)

Hi there,
I’m new to C# and monoGame. I have some problems with setting up the system. My game should run at linux and Win so decided to use OpenGL. If I run the basic MonoGame OpenGL project in Xamarin with mono.exe it stops working:
Problem Event Name: APPCRASH
Application Name: mono.exe
Application Version: 0.0.0.0
Fault Module Name: StackHash_2d06

(with MS.Net it works, the basic DirectX project works with both)

I installed:
Win7 64bit
MS VS 2015 Community
Xamarin Studio 5.10 (build 871)
MonoGame 3.4.0.455 (Xamarin Add-in)
mono-4.2.1.102
GTK# version 2.12.30

The Log-file shows these information and errors:
: Starting Xamarin Studio 5.10 (build 871)
: Running on Microsoft .NET 4.0.30319.42000
: Operating System: Windows 6.1.7601.65536 (64-bit)
: Found GTK# version 2.12.30
: Using GTK+ 2.24.23

: Initializing Runtime MS.NET
: Framework .NETCore,Version=v5.0 has unknown RuntimeVersion 5.0
: Framework .NETPortable,Version=v4.6 has unknown RuntimeVersion 4.6
: Framework .NETPortable,Version=v4.6,Profile=Profile151 has unknown RuntimeVersion 4.6
: Framework .NETPortable,Version=v4.6,Profile=Profile157 has unknown RuntimeVersion 4.6
: Framework .NETPortable,Version=v4.6,Profile=Profile31 has unknown RuntimeVersion 4.6
: Framework .NETPortable,Version=v4.6,Profile=Profile32 has unknown RuntimeVersion 4.6
: Framework .NETPortable,Version=v4.6,Profile=Profile44 has unknown RuntimeVersion 4.6
: Framework .NETPortable,Version=v4.6,Profile=Profile84 has unknown RuntimeVersion 4.6
: Framework .NETPortable,Version=v5.0 has unknown RuntimeVersion 5.0

: ANDROID: sdk: Looking for Android SDK…
: ANDROID: sdk: Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidSdkDirectory not found.
: ANDROID: sdk: Key HKLM\SOFTWARE\Novell\Mono for Android\AndroidSdkDirectory not found.
: ANDROID: sdk: Key HKCU\SOFTWARE\Xamarin\MonoAndroid\PrivateAndroidSdkPath not found.
: ANDROID: sdk: Key HKCU\SOFTWARE\Android SDK Tools\Path not found.
: ANDROID: sdk: Key HKLM\SOFTWARE\Android SDK Tools\Path found:
Path contains adb.exe in \platform-tools (C:\Program Files (x86)\Android\android-sdk).
: ANDROID: sdk: Looking for Android NDK…
: ANDROID: sdk: Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidNdkDirectory not found.
: ANDROID: sdk: Key HKLM\SOFTWARE\Novell\Mono for Android\AndroidNdkDirectory not found.
: ANDROID: sdk: Key HKCU\SOFTWARE\Novell\Mono for Android\JavaSdkDirectory found:
Path contains jarsigner.exe in \bin (C:\Program Files\Java\jdk1.7.0).
: ANDROID: Did not find Xamarin.Android
: ANDROID: Found Android SDK. API levels: (none)
: Xamarin.Android SDK not found, disabling Xamarin.Android addin

node classlib-gecko' is not defined on the documentation map node classlib-taglib-sharp’ is not defined on the documentation map
node `classlib-webkit’ is not defined on the documentation map

WARNING: Gtk-Warning: Error loading theme icon ‘document-save-as’ for stock: Failed to load icon
Stack trace:
at Gtk.Widget.gtksharp_widget_base_size_request(IntPtr widget, IntPtr requisition)
at Gtk.Widget.OnSizeRequested(Requisition& requisition)
at MonoDevelop.Components.Commands.CommandMenu.OnSizeRequested(Requisition& requisition)
at Gtk.Widget.sizerequested_cb(IntPtr widget, IntPtr requisition)
at Gtk.Application.gtk_main()
at Gtk.Application.Run()
at MonoDevelop.Ide.IdeApp.Run()
at MonoDevelop.Ide.IdeStartup.Run(MonoDevelopOptions options)
at MonoDevelop.Ide.IdeStartup.Main(String[] args, IdeCustomizer customizer)
at Xamarin.Startup.MainClass.Main(String[] args)

ERROR: Gtk-Critical: render_fallback_image: assertion ‘pixbuf != NULL’ failed
Stack trace:
at Gtk.Widget.gtksharp_widget_base_size_request(IntPtr widget, IntPtr requisition)
at Gtk.Widget.OnSizeRequested(Requisition& requisition)
at MonoDevelop.Components.Commands.CommandMenu.OnSizeRequested(Requisition& requisition)
at Gtk.Widget.sizerequested_cb(IntPtr widget, IntPtr requisition)
at Gtk.Application.gtk_main()
at Gtk.Application.Run()
at MonoDevelop.Ide.IdeApp.Run()
at MonoDevelop.Ide.IdeStartup.Run(MonoDevelopOptions options)
at MonoDevelop.Ide.IdeStartup.Main(String[] args, IdeCustomizer customizer)
at Xamarin.Startup.MainClass.Main(String[] args)

ERROR: GdkPixbuf-Critical: gdk_pixbuf_get_width: assertion ‘GDK_IS_PIXBUF (pixbuf)’ failed
Stack trace:
at Gtk.Widget.gtksharp_widget_base_size_request(IntPtr widget, IntPtr requisition)

ERROR: GLib-GObject-Critical: g_object_ref: assertion ‘G_IS_OBJECT (object)’ failed
Stack trace:
at Gtk.Widget.gtksharp_widget_base_size_request(IntPtr widget, IntPtr requisition)

WARNING: Gtk-Warning: Error loading theme icon ‘document-revert’ for stock: Failed to load icon
Stack trace:
at Gtk.Widget.gtksharp_widget_base_size_request(IntPtr widget, IntPtr requisition)

ERROR: Gtk-Critical: render_fallback_image: assertion ‘pixbuf != NULL’ failed
Stack trace:
at Gtk.Widget.gtksharp_widget_base_size_request(IntPtr widget, IntPtr requisition)

…more errors…
WARNING: Gtk-Warning: Error loading theme icon ‘document-save-as’ for stock: Failed to load icon
Stack trace:
at Gtk.Application.gtk_main()
at Gtk.Application.Run()
at MonoDevelop.Ide.IdeApp.Run()
at MonoDevelop.Ide.IdeStartup.Run(MonoDevelopOptions options)
at MonoDevelop.Ide.IdeStartup.Main(String[] args, IdeCustomizer customizer)
at Xamarin.Startup.MainClass.Main(String[] args)

ERROR: Gtk-Critical: render_fallback_image: assertion ‘pixbuf != NULL’ failed
Stack trace:
at Gtk.Application.gtk_main()
…more errors…

WARNING: Invalid category using default category. Template id=‘MonoGameSharedProject’, category=‘C#/MonoGame’.
…more warnings…
WARNING: Invalid category using default category. Template id=‘MonoGameForOUYAProject’, category=‘C#/MonoGame’.

INFO: Initializing Runtime Mono 4.2.1 (Visual)
INFO: Add-in loaded: MonoDevelop.HexEditor
WARNING: Gtk-Warning: Error loading theme icon ‘system-run’ for stock: Failed to load icon
Stack trace:
at Gtk.IconSet.gtk_icon_set_render_icon(IntPtr raw, IntPtr style, Int32 direction, Int32 state, Int32 size, IntPtr widget, IntPtr detail)
at Gtk.IconSet.RenderIcon(Style style, TextDirection direction, StateType state, IconSize size, Widget widget, String detail)
at Xwt.GtkBackend.GtkWorkarounds.RenderIcon(IconSet iconset, Style style, TextDirection direction, StateType state, IconSize size, Widget widget, String detail, Double scale)
at Xwt.GtkBackend.ImageHandler.CreateBitmap(String stockId, Double width, Double height, Double scaleFactor)
…many more at’s …

ERROR: Gtk-Critical: render_fallback_image: assertion ‘pixbuf != NULL’ failed
Stack trace:
at Gtk.IconSet.gtk_icon_set_render_icon

ERROR: GdkPixbuf-Critical: gdk_pixbuf_get_width: assertion ‘GDK_IS_PIXBUF (pixbuf)’ failed
Stack trace:
at Gtk.IconSet.gtk_icon_set_render_icon

ERROR: GLib-GObject-Critical: g_object_ref: assertion ‘G_IS_OBJECT (object)’ failed
Stack trace:
at Gtk.IconSet.gtk_icon_set_render_icon

ERROR: GLib-GObject-Critical: g_object_ref: assertion ‘G_IS_OBJECT (object)’ failed
Stack trace:
at Xwt.GtkBackend.GtkWorkarounds.gtk_icon_set_render_icon_scaled

INFO: Add-in loaded: MonoDevelop.Debugger.Soft.AspNet
INFO: Add-in loaded: MonoDevelop.Debugger.Win32
WARNING: Gtk-Warning: Error loading theme icon ‘system-run’ for stock: Failed to load icon
Stack trace:
at Gtk.Widget.gtksharp_widget_base_size_request(IntPtr widget, IntPtr requisition)
…many more warings, errors…

Someone has any Idea how I could fix that? If more information is needed please write.

still dont work :frowning:
Is it normal that MonoGame.Framework.Linux is in the package folder if I select the basic MonoGame OpenGL project in Xamarin at Windows?
If I exchange it With WindowsGL packkage it still dont work with mono.
Is there any instruction for idiots?

If you are trying to run OpenGL, I have found there is no RISK to this, but has prevented any issues,

Put the Windows AND Linux version of the OpenGL for monogame in there… (Use Nuget Package manager)

Also make sure it DOES include the libSDL that comes with the linux version.

I have done this and ran a full MonoGame app on windows and linux back and forth without a recompile with no issues.

Thank you for an answer,
I already tried Windows and Linux OpenGL package together but it didn’t work as well.

Also make sure it DOES include the libSDL that comes with the linux version.

I’m not sure about this.
If I go to
C:\Users\Username\Documents\Projects\Projectname\packages\MonoGame.Framework.Linux.3.4.0.459\lib\net40
I have MonoGame.Framework.dll, OpenTK.dll and Tao.Sdl.dll in there.
If I go to
C:\Users\Username\Documents\Projects\Projectname\packages\MonoGame.Framework.WindowsGL.3.4.0.459\lib\net40
I have MonoGame.Framework.dll, MonoGame.Framework.xml, OpenTK.dll in there. (Tao.Sdl.dll is missing here)
But Tao.Sdl.dll is located at …\Projectname\bin\Debug close to the Projectname.exe file. This Tao.Sdl.dll-file has the same size as in the Linux-Framework folder.

If I add SDL with Package manger I get an error:
Adding ‘SDL.redist 1.2.15.16’ to MonoGame OpenGL Testproject.
Could not install package ‘SDL.redist 1.2.15.16’. You are trying to install this package into a project that targets ‘.NETFramework,Version=v4.5’, but the package does not contain any assembly references or content files that are compatible with that framework.

I have done this and ran a full MonoGame app on windows and linux back and forth without a recompile with no issues.

So you compile it once (at Linux or Win) and have two executable files (one L, one Win)? So far I only get an .exe file.

If you are trying to run OpenGL, I have found there is no RISK to this, but has prevented any issues,

Basically I want one source code for Win and Linux (C#) with easy graphic output (MonoGame -> OpenGL (so I can use Win and Linux), or can MonoGame run the same code with DirectX at Win and OpenGL/DirectX at Linux?).
To start with something I try to run
Xamarin Studio -> New -> Solution -> Others -> Miscellaneous -> MonoGame Application (Open GL)
with mono (Run -> Run With -> Mono 4.2.1 (Visual)).

If I add this to source code:
using SdlDotNet;
using Tao.OpenGl;
using Tao.Sdl;
only Tao.Sdl; is working

(update the Linux framework dont help)

MonoGame DirectX as far as I know doesnt require any different code… just a recompile using a different MonoGame Reference.(as well as a recompile of your Content to xnb files)

also no, when you put the MonoGame linux and WindowsGL together you get 1 exe that will work on both platforms.
Also sorry it is supposed to be called Tao.SDL - mistake on my memory.

If you need I can create a dummy project and send to you and you can compare what is different as well as see if my dummy version will actually run for you to make sure it is a problem of source or missing requirements on your computer or something…

You would do me a great favour with that.

(I uploaded it as well)
Open_GL_Test__WindowsGL.zip (at file-upload.net)

I actually ran your project and got the issue loading it myself, and figured out the simple fix is to completely delete the original package references… then re-add them from nuget. The original build from xamarin includes what seems to be a broken linux package that doesnt fix with just updating it so again, just remove it, re-add both linux and windows and you shouldnt have any problems. I did so in your project to make sure it wasnt just something from my own installation.

Strange. I removed the packages and added them again. Still get the error :frowning:

got the issue loading it myself

You got issue while loding it in Xamarin or at running with mono?

It don’t show any error in source code, only a warning:
“Game1.cs(19,15): warning CS0414: The private field `sdftgzhjklk.Game1.spriteBatch’ is assigned but its value is never used”

Xamarin. Im on windows :wink: Id recommend you try reinstalling your monogame templates though if that didnt fix it >.>

Using Xamarin on Windows as well. I installed Monogame several times but It didn’t help. Is your default Xamarin project different to mine? Would it be possible to upload a working project :slightly_smiling: ?

EDIT:
Heureka! It is working now.!
I added a SDL2.dll (win-64bit) close to the .exe file and the program is running.

(Is that normal? -> in: new thread )

Yeah my default was the same as yours… but the linux package was supposed to come with the sdl shiz u needed…