C# 如何从自托管asp.net核心应用程序调用可执行文件?

C# 如何从自托管asp.net核心应用程序调用可执行文件?,c#,asp.net-web-api,asp.net-core,ipc,.net-core,C#,Asp.net Web Api,Asp.net Core,Ipc,.net Core,是否可以使用参数运行.exe文件,并从asp.net core自托管应用程序接收返回值?如果是-如何 我尝试将ConsoleApp1.exe放入项目根文件夹,并从控制器调用LaunchCommandLineApp,但没有成功:exeProcess属性,其中填充了错误 static void LaunchCommandLineApp() { // For the example. const string ex1 = "C:\\"; const string ex2 = "

是否可以使用参数运行
.exe
文件,并从
asp.net core
自托管应用程序接收返回值?如果是-如何

我尝试将
ConsoleApp1.exe
放入项目根文件夹,并从控制器调用
LaunchCommandLineApp
,但没有成功:
exeProcess
属性,其中填充了错误

static void LaunchCommandLineApp()
{
    // For the example.
    const string ex1 = "C:\\";
    const string ex2 = "C:\\Dir";

    // Use ProcessStartInfo class.
    ProcessStartInfo startInfo = new ProcessStartInfo();
    startInfo.CreateNoWindow = false;
    startInfo.UseShellExecute = false;
    startInfo.FileName = "ConsoleApp1.exe";
    //startInfo.WindowStyle = ProcessWindowStyle.Hidden;
    startInfo.Arguments = "-f j -o \"" + ex1 + "\" -z 1.0 -s y " + ex2;

    try
    {
        // Start the process with the info we specified.
        // Call WaitForExit and then the using-statement will close.
        using (Process exeProcess = Process.Start(startInfo))
        {
            exeProcess.WaitForExit();
        }
    }
    catch (Exception ex)
    {
        // Log error.
    }
}

exeProcess上指出了哪些错误?请查看编辑您是否确实需要这些属性?如果不是,你为什么关心他们的错误?因为
ConsoleApp1.exe
没有真正执行我不知道这是否与错误有关,只是认为这可能很重要