简体   繁体   中英

Run a C# program to launch another C# program in mono

I am currently running a server software program that is written in C#, and I am attempting to
add support for this .net software on linux. Almost everything works as intended under mono, however, a few things do not work. For instance, upon a successful shutdown of the server software, another external program written in C# is supposed to pop up instantly and send heartbeats of data from a text file. In a .net environment, such as windows 7, this works simple with

Process.Start("Heartbeat.exe");

And that's it. It pops up.

Annnnnnnnd, when the server software detects that the host OS is running mono, upon the server shutdown function, I have attempted to run other code. The above code has no effect. I attempted this, but I probably have no clue what I'm doing.

ProcessStartInfo procInfo = new ProcessStartInfo();
procInfo.UseShellExecute = false;
procInfo.FileName = "Heartbeat.exe";
Process.Start(procInfo);  

This doesn't work either. I have tried to run a .sh to run the .exe as well with the mono args, but it was highly inefficient. Any help and all help is greatly appreciated. (Before you guys yell at me to read the mono and ProcessStartInfo APIs like most people, I read them both, and I still understand nothing. Also the mono API is weird.)

Edit:

Thank you Lex Li for answering, but when using

Process.Start("mono Heartbeat.exe")

I get this error:

Error when getting information for file '/home/me/Desktop/LCDev/mono Heartbeat.exe': No such file or directory

I assume that the above code attempts to run a program called "mono Heartbeat.exe", instead of opening Heartbeat.exe with mono.

C#应用程序必须在Linux上使用mono启动,因此您应该使用

Process.Start("mono", "full_path_of_your_exe");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM