5

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.

1 Answer 1

10

C# applications must be started on Linux using mono, so you should use

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

Sign up to request clarification or add additional context in comments.

4 Comments

Error when getting information for file '/home/me/Desktop/LCDev/mono Heartbeat.exe': No such file or directory
Just edited. Forgot that the path of your exe should be passed as parameter.
Ah, it worked when I added ProcessStartInfo.CreateNoWindow = true;
I get this error: "xdg-open: unexpected argument 'full_path_of_your_exe'"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.