c# – 从.NET到单声道的系统调用

我正在尝试使用mono进行外部系统调用.我想知道是否可以模仿下面的示例(当然我正在寻找跨平台支持).

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命名空间的不存在引用(不知道如何发生),第一个实现不起作用,只要使用System.Diagnostics命名空间,此代码块就可以工作.

解决方法

我不确定这是否是您想要的,但请查看我在 Windows Service Application Controller中发布的代码示例,这在Mono中有效.

相关文章

项目中经常遇到CSV文件的读写需求,其中的难点主要是CSV文件...
简介 本文的初衷是希望帮助那些有其它平台视觉算法开发经验的...
这篇文章主要简单记录一下C#项目的dll文件管理方法,以便后期...
在C#中的使用JSON序列化及反序列化时,推荐使用Json.NET——...
事件总线是对发布-订阅模式的一种实现,是一种集中式事件处理...
通用翻译API的HTTPS 地址为https://fanyi-api.baidu.com/api...