I'm trying to make an external system call using mono. I'd like to know if it's possible to emulate something like the example below (Of course I'm looking for cross platform support).
public static int ExecuteExternalApp()
{
int ExitCode = -1;
Process Process = new Process(); ;
//Defining the filename of the app
Process.StartInfo.FileName = "java";
//Assigning the args to the filename
Process.StartInfo.Arguments = @"-jar """ + ConfigurationManager.AppSettings["JarPath"].ToString();
try
{
//Starting the process
Process.Start();
//Waiting for the process to exit
Process.WaitForExit();
//Grabbing the exit code
ExitCode = Process.ExitCode;
//Close the process
Process.Close();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return ExitCode;
}
**UPDATE: This code does work in mono. The first implementation did not work because of a non-existent reference to the System namespace (no idea of how that happened), this code block works as long as the System.Diagnostics namespace is used.