Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 753
voice Avatar asked Sep 15 '13 03:09

voice


People also ask

Where do I run my AC code?

Step 1: Open turbo C IDE(Integrated Development Environment), click on File and then click on New. Step 2: Write the C program code. Step 3: Click on Compile or press Alt + F9 to compile the code. Step 4: Click on Run or press Ctrl + F9 to run the code.

Can you run C on Windows?

If you want to run C or C++ programs in your Windows operating system, then you need to have the right compilers. The MinGW compiler is a well known and widely used software for installing GCC and G++ compilers for the C and C++ programming languages.

How run C file in terminal or code?

After writing the code, right-click on the program, as shown below. Click on the Run Code option or press Ctrl + Alt + N from the button.


1 Answers

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

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

like image 199
Lex Li Avatar answered Oct 01 '22 02:10

Lex Li