从另一个 C# 可执行文件中在 linux 中运行 c# 可执行文件时,“没有这样的文件或目录”

Abh*_*hna 5 c# .net-core

我正在尝试以下操作:

1) 从另一个可执行文件运行 ac# 可执行文件。

我正在使用.net core 3.1

问题

  • 当我在 Linux 中运行该应用程序时,出现以下错误。
Error =>No such file or directory    
 Exception encountered => System.ComponentModel.Win32Exception (2): No such file or directory
  at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean
  redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean
  setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32&
  stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal,
  Boolean throwOnNoExec)
         at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
         at System.Diagnostics.Process.Start()
         at ConsoleMQTT_Sender.ProcessClass.LaunchProcess(....) in ...
Run Code Online (Sandbox Code Playgroud)

该应用程序是通过在linux环境中运行的jenkins生成的。

该文件存在,但出现上述错误。

这是跨平台问题吗?或者权限问题?

运行第一个可执行文件时的标志

  • dotnetfirstexecutable.dll --secondexecutablepath“/opt/publish/xyz.dll”
  • dotnet firstexecutable.dll --secondexecutablepath“dotnet /opt/publish/xyz.dll”

都给出相同的例外

我如何触发 c# 控制台应用程序内的可执行文件:

            process.EnableRaisingEvents = true;
            process.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(process_OutputDataReceived);
            process.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(process_ErrorDataReceived);

            process.StartInfo.FileName = firstexecutablepath;

                process.StartInfo.Arguments = "--secondexecutablepath \"" + executablepath + "\"";
            process.StartInfo.RedirectStandardError = true;
            process.StartInfo.RedirectStandardOutput = true;

            process.Start();
            process.WaitForExit();
Run Code Online (Sandbox Code Playgroud)