Reputation: 142
I'd like to run Mono(C#) code on a Web server that does not have Mono Runtime installed. Since mkbundle is able to produce native code, I am first trying to get a plain "Hello World" script to work on both sides, which runs locally but not on the Web server.
C# HelloWorld.cs script:
using System;
public class HelloWorld
{
public static void Main()
{
System.Console.WriteLine("Hello, World!");
}
}
I do compiling and bundling using:
$ gmcs HelloWorld.cs -out:HelloWorld.exe
$ mkbundle -o helloworld HelloWorld.exe --static --deps
My only permitted way to execute this script on the web server is by using a PHP script, which has the following:
$cmd = "./helloworld";
exec($cmd, $array, $return_code);
var_dump($array);
//passthru($cmd, $return_code);
var_dump($return_code);
Locally, this script works and I get the following response:
array(1) { [0]=> string(13) "Hello, World!" } int(0)
But on the web server this is all the script returns
array(0) { } int(11)
Bash exit code 11 is non-standard according to this and this exit codelists.
Both machines are on a 64bit Linux and a "file helloworld" returns the following...
On Local machine:
helloworld: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=fbc9731fb13202c604b025ba3eefe51c69dc40d8, not stripped
On Web server:
helloworld: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), stripped
Might "dynamically linked (uses shared libs), stripped" still mean that some embedded libraries or mono runtime be still missing?
Upvotes: 0
Views: 240
Reputation: 142
I created a virtual machine with the same OS as the Web Server, when running the bundle I got 'Segmentation fault (core dumped)', which has the exit code '11'. mkbundle is not a fully compatible way to deploy Mono written software on Linux machines.
So in the end I installed Mono on the virtual machine, compiled and mkbundle'd the code, and after uploading the file to the Web Server it was able to execute it.
Upvotes: 0