Reputation: 6501
I have a simple C# Mono 2.10 application running on CentOS 5.5 that calls
Process.Start("/path/to/myapp/myapp.exe","-someArgs");
I am able to get a process ID back and running with
mono --trace=N:System.Diagnostics
Shows me a stack that seems to indicate that Process.Start returned true:
LEAVE: System.Diagnostics.Process:Start_noshell (System.Diagnostics.ProcessStartInfo,System.Diagnostics.Process)TRUE:1
LEAVE: System.Diagnostics.Process:Start_common (System.Diagnostics.ProcessStartInfo,System.Diagnostics.Process)TRUE:1
LEAVE: System.Diagnostics.Process:Start ()TRUE:1
LEAVE: (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start ()TRUE:1
Which I assume means the process was spawned without an exception like FileNotFound etc..
However, the process seems to exit immediately and the exit code I get is 255. I assume this is a Linux exit code with some obvious meaning but I can't find anything of use on the tubes.
When launching the exact same application directly via
mono /path/to/myapp/myapp.exe -someArgs
The application launches correctly without any exception and works as expected.
Any clue what I am screwing up?
Upvotes: 3
Views: 4705
Reputation: 3230
You can start process using this overloading of Process.Start:
Process.Start("/bin/bash", "-c \"echo 'Hello World!'\"");
Don't know why, but it works.
Upvotes: 0
Reputation: 13600
Is the file /path/to/myapp/myapp.exe
an executable file (chmod +x /path/to/myapp/myapp.exe
)? Mono 2.10 does check to see if the process it's starting is a managed executable, and if so will implicitly use the currently executing mono to launch the new process, e.g. Mono's CreateProcess source. CreateProcess
contains all the details, but among them:
If Process.Start
still fails to start your process, then that's a probable mono bug and we'd love to have a bug reported for it. :-)
Upvotes: 4
Reputation: 38643
The problem is that Linux itself doesn't know that it needs to use Mono to run CIL .exe binaries, so it tries to use ld-linux.so as the loader, which for obvious reasons fails.
You need to invoke mono with /path/to/myapp.exe as an arg.
FWIW, an exit code of 255 is just "error".
Upvotes: 2
Reputation: 564861
Try launching "mono" as the process, and use "/path/to/myapp/myapp.exe -someArgs" as the command line arguments. That will cause the Process.Start to behave more like your normal application launch.
Upvotes: 2