3

Possible Duplicate:
How to convert a simple .Net console project a into portable exe with Mono and mkbundle?

I have a C# program which was written on windows, I need to transfer it to linux server.
However client doesn't want instal mono on his server, so I want to find a way to make it easy for him.
Is it possible to convert this program in such a format that it will run on linux without mono installed there?

Community
  • 1
  • 1
Sunny88
  • 2,860
  • 3
  • 24
  • 25

2 Answers2

6

C# programs are based on the Common Language Runtime. They are not native applications. So, as far as I know, there's no way of running a program made in C# without having the CLR on the system. Currently, there are only two of them: .NET (Windows) and Mono.

So I don't think there's a way of running your program on a non-Windows machine without installing Mono.

Thorsten Dittmar
  • 55,956
  • 8
  • 91
  • 139
  • 2
    So this thing called [mkbundle](http://stackoverflow.com/questions/1321207/how-to-convert-a-simple-net-console-project-a-into-portable-exe-with-mono-and-m) will not help me? – Sunny88 Dec 29 '11 at 13:29
  • Well, as I understand, mkbundle will bundle mono with your application so that it doesn't have to be installed. This might work too, but I haven't tried. You should keep in mind that not every .NET application may also run on Mono! This (as was said in the comments) depends on whether portability was an issue during development. This includes, among others, avoiding hardcoded paths, usage of OS specific features/P-Invoke calls, or the use of features that are not part of Mono. You should test the application on a Linux machine using Mono first. – Thorsten Dittmar Dec 29 '11 at 14:06
  • 1
    mkbundle creates a native binary, so it actually does do what he wants – jstedfast Dec 29 '11 at 21:24
  • I agree with @jstedfast. You do want mkbundle with the --static option – IanNorton Dec 29 '11 at 23:09
6

You need to use mkbundle with the --static option if your target system does not have mono installed.

Bundles in addition support a --static flag. The --static flag causes mkbundle to generate a static executable that statically links the Mono runtime. Be advised that this option will trigger the LGPL requirement that you still distribute the independent pieces to your user so he can manually upgrade his Mono runtime if he chooses to do so

IanNorton
  • 7,145
  • 2
  • 25
  • 28
  • Doesn't work for me. I get `The assembly mscorlib.dll was not found or could not be loaded. It should have been installed in the /usr/lib/mono/4.5/mscorlib.dll' directory.` I wonder what I'm doing wrong here – Nicholas DiPiazza Nov 18 '17 at 07:58