[Solved] Issue with MonoGame 3.8 on Ubuntu

I’m trying to run a MonoGame 3.8 build on my Ubuntu machine.
I created a new project with template “MonoGame Cross-Platform Desktop Application (OpenGl)” in VisualStudio2019 on Windows10. It compiles and runs fine on Windows10. When running the release on my Ubuntu machine it gives an error.
ERROR: Cannot load assembly (bad file format) Exception of type ‘IKVM.Reflection.BadImageFormatException’ was thrown.

I tried different solutions with same result:

Anybody have an idea what I need to do to make it work on Linux (Ubuntu) ?

I don’t know but maybe you have to compile it again on Linux to get something that runs under Linux? If you have the project (not release but the complete project) on Linux and set up everything correctly then dotnet run from the terminal should be enough to trigger a build and run of the project.

On Ubuntu you need dotnet-sdk-3.1, MonoGame templates and optional Wine if you want to build effects on Linux.

If you use MonoGame Kickstarter make sure to use the version from the master branch.

Hi Kwyrky,

Thank you for your suggestion and yes it is my next step to get it working.

I was hoping to avoid compiling on every platform.
I do not have a mac computer, so it means I need to buy a mac computer to compile it there. :confused:

So I need to compile it on a Windows machine, Linux machine and a mac machine every time I change something in the code. I’m not sure it is the best practice.

I agree that it would be nice to be able to compile for all platform would be possible from any platform and maybe it is. Somebody with more knowledge should comment on this.

On Linux the native format is ELF I believe and Exe is the fileextension used on Windows. Maybe the Exe file can be run with Wine under Linux but not sure if this works in this case.

Good news: Turns out you can compile for different platforms e.g. on Windows for Linux!

Good news: Turns out you can compile for different platforms e.g. on Windows for Linux!

Cool :slight_smile: Can you tell me how to do it? Link? Guide?

It should be possible using Visual Studio 2019 too I guess but did only try with the command line so far. You can use dotnet publish --runtime linux-x64 and dotnet publish --runtime win-x64.

1 Like

Thank you for the help.
It compiles on Windows and run on Ubuntu now. :smiley:

1 Like

Cool stuff! I did try and compilation on Linux did work too targeting Windows / Linux and MacOS!

Just search for dotnet publish.

Also I looked into Visual Studio and there you can right click a projects and there should be a publish option in the menu achieving the same I guess. Leave feedback what you found out. :slight_smile:

If you have time please leave feedback on MonoGame Kickstarter too :grinning:

1 Like