Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mono Process.Start returning ExitCode 255?

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?

like image 373
Brad Cunningham Avatar asked Aug 13 '26 09:08

Brad Cunningham


2 Answers

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:

  • The process must be executable
  • The process must be a managed binary

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. :-)

like image 61
jonp Avatar answered Aug 15 '26 01:08

jonp


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.

like image 39
Reed Copsey Avatar answered Aug 15 '26 00:08

Reed Copsey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!