4
monoを使用して外部システムコールをしようとしています。下の例のようなものをエミュレートすることができるかどうかを知りたいと思います(もちろん、クロスプラットフォームサポートを探しています)。.NETからモノラルへのシステムコール
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;
}
**アップデート:このコードはモノラルで動作します。最初の実装は、System名前空間への参照が存在しないために動作しませんでした。SystemException構造体の名前空間が使用されている限り、このコードブロックは機能します。
私はSystem.Diagnostics名前空間を最初から提供するパッケージの中に見つけることができませんでした。どのように参照しましたか? –
私には分かりませんが、私が投稿したコードはMonoを使って作業しますが、VisualStudio + .NETでコンパイルしました。 –
Monoのドキュメント(http://www.go-mono.com/docs/index.aspx?link=N%3ASystem.Diagnostics)を見ると、System.Diagnosticsを参照する際に問題はありません。 –