tags:

views:

83

answers:

3

I have created a c# application in ubuntu using monodevelop. It is running well in ubuntu. I tried to run that application(firstgtk.exe file created after running in ubuntu)in windows.But it showing error message.How can i make to portable in both linux and windows?

The error message is:

when i click the firstgtk.exe file, a command prompt has come.It is blank. At the same moment microsoft message(send Error report or don't send):

firstgtk has encountered a problem and needs to close.

When i click don't send button, command prompt and message box are gone.

A: 

Your code should be portable between Linux and Windows. Alas, the binaries are not. ...

Edit: As commenters have pointed out, Mono does produce and use PE executables, though other issues may limit portability.

Karmastan
Won't he need to have Mono installed on Windows before he can compile for Mono on Windows?
FrustratedWithFormsDesigner
I don't think this is true. Mono produces PE files which the mono runtime loads and executes. I believe the same binary works on both platforms.
codekaizen
@codekaizen: Yeah? Cool. But in that case he'd still need the Mono platform on Windows. It's not even clear if he has that.
FrustratedWithFormsDesigner
@codekaizen: I looked through the [Mono FAQ](http://www.mono-project.com/FAQ:_Technical), and it appears that "100% .NET" apps generated by MS tools are binary compatible to be run under Mono/Linux. It doesn't mention anything about binaries generated by Mono/Linux being natively usable under Windows. Maybe it's a compile time flag?
Karmastan
The binary format used by Mono and .NET is the same. However, platforms do have differences - for example, paths hardcoded into strings may not work on all platforms, and the same libraries may not be available everywhere. You can handle usually these things with one binary, using runtime checks for the host platform.
mhutch
@FrustratedWithFormsDesigner: Yea, he needs to have the Mono framework installed on both platforms, then the binary should work. @mhutch: Right, you still need to abstract platform access. DllImport on Windows DLLs, for example, won't work on Linux.
codekaizen
You don't have to have the Mono framework installed on Windows if you don't want to. The same binaries will run on Mono for Linux, Mono for Windows, Mono for OSX, or .Net on Windows.
jpobst
+3  A: 

Mono compiles down to CIL code and is completely portable to .NET or Mono on other platforms. I can compile my C# code on a Mac and run the resulting EXE on Linux or Windows under either .NET or Mono.

Without the actual error message we can only guess the issue here. That said, in my experience, the most common reasons an application written in Mono on Linux/UNIX would create an error on Windows are pathnames with platform specific path separators or case sensitivity issues. The Windows file system is not case sensitive but they are on Linux/UNIX.

Another possibility is that you are using Mono on one platform and trying to run it on .NET on the other. Mono ships with a number of libraries that are not present in .NET on Windows.

Actually, I guess a final possibility is that GTK# is a common way to produce GUI code on Mono. GTK# relies on the GTK+ C library being present which is very common on Linux but unlikely on Windows unless it has been explicitly installed.

We really need to know what the error message was.

Justin
Now that more info has been added, I can see that my last guess was correct. Anthony jumped in with the right answer above. GTK# has to be installed.
Justin
+1  A: 

If you're using Gtk#, your app is portable between Windows and Linux. My guess is that you don't have Gtk# installed correctly (or at all?) on Windows. You can download from here. As of this time the latest version is 2.12.10.

anthony
Thanks, it is working. I have created another simple java console project.While double clicking it's exe file,same type of error is coming.Any thing i need to install?
Nikhil K
I was going to say "Good guess Anthony" but I see the question was updated to provide more info. So, instead I will say "Good answer". :-)
Justin