我正在尝试与当前进程的子进程运行相同的进程。下面显示的代码在Windows下工作正常,但在Linux中失败并出现错误
找不到与命令“ dotnet-MyDll.dll”匹配的可执行文件
var processInfo = new ProcessStartInfo
{
FileName = "dotnet",
Arguments = "MyDll.dll " + id.ToString()
};
Console.WriteLine("Starting child process...");
var process = Process.Start(processInfo);
return process;
我也尝试过 FileName =“ dotnet MyDll.dll” + id.ToString(), 但最终会出现不同的错误 未处理的异常:System.ComponentModel.Win32Exception:没有这样的文件或目录
我也尝试过
var parentP = Process.GetCurrentProcess();
string fullPath = parentP.MainModule.FileName;
var command = fullPath+" "+Assembly.GetEntryAssembly().Location+" "+ id.ToString();
Console.WriteLine("Command = "+command);
var processInfo = new ProcessStartInfo
{
FileName = command
};
var process = Process.Start(processInfo);
仍然 未处理的异常:System.ComponentModel.Win32Exception:没有这样的文件或目录
我也尝试过:
var parrentP = Process.GetCurrentProcess();
string fullPath = parrentP.MainModule.FileName;
var command = "\"" + fullPath + "\" " ;
var args = Assembly.GetEntryAssembly().Location + " " + id;
var processInfo = new ProcessStartInfo
{
FileName = command,
Arguments = args
};
var process = Process.Start(processInfo);
Exception No such file or directory
Exception at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
在具有dotnet核心的Linux下再次运行当前正在运行的dll的正确方法是什么