I'm trying to figure out how to compile a Mono project (in Xamarin Studio) on Windows and then run the .exe on Linux. So far, I get
Cannot open assembly 'Program.exe': File does not contain a valid CIL image.
when I try to run the executable on Linux.
I'm compiling with the same commands on Windows as when I compile on Linux, mcs and then try to run it with mono.
What I'm I missing here?
Thanks in advance.
Xamarin Studio is an IDE and when it compiles your application on Windows, it is very likely to use .NET Framework by default and the latest .NET bits (4.5.1 and above) do not yet have counterpart on Mono.
Do install a Linux machine and MonoDevelop on it and that makes sure all bits you compile are working.
Related
I have developed a game on Windows 7 (64bit) in Visual Studio 2015 with the language C# and the MonoGame framework. The game works fine on Windows, but I also wanted to make the game to be playable on Linux. Therefore I installed VirtualBox with Ubuntu 15.10 (64bit) on my Windows PC, to test if I can make my game running on Ubuntu.
After trying to compile the game in different ways with no solution in sight, I came to the conclusion to ask a few questions here about deploying MonoGame to Linux:
Is it possible to compile a MonoGame game in VisualStudio 2015 on Windows for Linux in a...
1.1. MonoGame Linux Project?
1.2. MonoGame Windows OpenGL Project?
1.3. MonoGame Windows Project? (which my game currently is)
If [1.] what are the requirements and what programs need to be installed on Linux to run this [1.x] build?
Is it possible (and recommended) to compile the game in MonoDevelop on a virtual Ubuntu machine?
Is it even possible to run a MonoGame game on a virtual Ubuntu machine?
What is the proper executable file extension for a game on Linux? (Because Linux Project on Windows is only building a .exe)
I have almost no experience with Linux, so I hope someone can answer me these questions, maybe someone who has experience with porting a MonoGame game to linux.
Thanks.
Though the question is a few years old, it's deserving of an answer. I managed to make cross-platform builds for a game built in MonoGame through Mono's mkbundle. Here is a great tutorial for doing so on Windows.
You'll want to download the latest Mono version and append an "exe" extension to the file located at C:\Program Files (x86)\mono\bin\mono. Next download the appropriate runtime for the platform you want to deploy to, give it a "zip" extension, and extract it into the following path: C:\Users\youruserhere\Documents.mono\targets
After that, you should be ready to build; open up a Command Prompt and enter mkbundle --local-targets. If everything went smoothly, the runtimes you have installed should be displayed. After that is a matter of building an exe to the target platform.
Here's an example for building an application to Ubuntu: mkbundle HelloWorldConsole.exe --simple -o HelloWorldBundleUbuntu --cross mono-5.10.0-ubuntu-16.04-x64
Keep in mind that some classes not implemented in Mono, such as WebBrowser, will cause the build to fail. If this is the case, you may need to find a workaround.
With this you can run the file in Linux by entering ./HelloWorldBundleUbuntu in a Terminal. I've had no issues running the game this way in a virtual machine.
Lastly, if you want to go the .NET Core route, MonoGame has a WIP core fork that you can use, though I'm unsure how well it works.
To add to an already year old answer by Kimimaru, there's also the possibility to use MonoKickstart to get your Monogame executables up and running on Mac and Linux without the need to bundle anything. This is especially handy if your projects are a little difficult to bundle, because of third-party libraries or otherwise.
You simply unpack the Kickstart archive and paste your Windows executable ontop. By editing the .kick files to point to the appropriate executable, they will act as an intermediary to run your programs using mono (which is provided, as well, no need to install on target machine).
https://github.com/mrhelmut/MonoKickstart
I have a program on .NET 4 for Windows. I'm trying to port it for Mac computers with mono and Xamarin studio.
I use this code for building:
macpack -m:1 -o:. -r:/Library/Frameworks/Mono.framework/Versions/Current/lib/ -r:/Library/Python/2.7/site-packages/emgucv/lib -r:/Library/Python/2.7/site-packages/emgucv/bin -r:Assimp32.dll -r:Assimp64.dll -r:cvextern.dll -r:Emgu.CV.dll -r:Emgu.Util.dll -r:libegl.dll -r:libglesv2.dll -r:OpenTK.dll -r:OpenTK.GLControl.dll -r:RH.ImageListView.dll -r:blending.fs -r:blending.vs -r:blendingPl.vs -r:idle.fs -r:idle.vs -r:skelet.vs -r:sprite.png -r:./Libraries -r:./Models -r:./Plugin -r:./Resources -r:./Stages -r:./"Haar Cascades" -n:HeadShop -a:RH.MyProgram.exe
where I attach mono lib, emgucv lib and all my dll's from debug folder..
All works good on my machine (where I have mono, xamarin studio and all libs installed), but on a client machine - program doesn't run. It doesn't give any errors, just doesn't appear..
Should user install mono or something else for launch program or my command for building is wrong?
I guess you have to install at least the Mono Runtime. Since it seems not possible to install it alone, you may have to install the Mono Mac Package.
However, since mono translate C# code into Common Intermediate Language you have to install at least something that can interpret that code and translate/run it on the CPU - An installation is needed in any case.
I have a odd problem
platform:.net 4.0, win7 32/64, VS2010
MIPCChannel.dll: C++/cli mixed dll
NewClient.exe: C# which refrenced the MIPCChannel.dll
The Problem is when i deploy my program, someone try to run NewClient.exe gives error:CLR20r3, System.BadImageFormatException
I do below steps:
i deference the MIPCChannel.dll everything goes ok
or i install VS2010 redistribute everything goes ok
but i don't want to reply redistribute, and i want to know where the problem is!
Mixed mode C++/CLI DLLs must be linked against the dynamic runtime. That means you must deploy the dynamic runtime to any machine on which you hope to run such a DLL.
Since you are using VS2010, you don't need to deploy the runtime using the redistributable package, although that is the recommended way to do so. You can instead deploy specific Visual C++ DLLs to the application local folder.
Check if it is x86 or x64 problem. It is likely that you develop in 64 bit environment but deployed that in 32 bit environment.
I'm using MonoDevelop 2.8.5 and I'm trying to compile a moonlight application, but it fails. I created a brand new Moonlight Application Project and tried to compile it, but it fails with the following error.
Error: Framework 'Moonlight / Silverlight 4.0' not installed. (MoonlightTest)
In this question from October 2011 one of the developers of MonoDevelop states that is not possible to do this without some major hassle.
Is this still true with the new version(s) of MonoDevelop out?
If so, how can I compile Moonlight Application Projects in MonoDevelop if I'm willing to go through some hassle?
This is a bit of "psychic debugging" but I've run into it a lot in linux and imagine you might have the same problem happening on OS X. Is the compiler that Monodevelop is looking for exactly the same as the version you installed? It might be something as simple as the folder being called Moonlight1.3 vs Moonlight1.3.1. Look at the build output and see what version it is looking for then look in your applications folder (via terminal the app folder in the finder might hide the info) and check that they are the same.
Guys I created a console application in Visual Studio 2010. It targets the .NET framework 2.0. When I run the application is Visual Studio, it works perfect. I then exited Visual Studio and copied the executable to my C:\Windows\System32 directory. When I open a command prompt window and try to execute my program, it comes up with a standard Windows message box with an error that says "Unable to find a version of the runtime to run this application". I know I got the .NET framework installed.
I then copied the executable to my C:\Users\Public directory and tried to execute it from there and it worked fine. So I am assuming this is some kind of security issue or something? What do I need to do make the application work from C:\windows\system32 directory?
I am using Windows 7 64-bit, by the way. The application was compiled to target .NET 2.0 framework and 32-bit machines.
I think on a 64-bit machine you'll have to put it into c:\Windows\SysWOW64, which contains all the 32-bit stuff retained for compatability (everything in system32 should be x64).