在 Linux 上运行我的 .Net Core 应用程序时,我面临以下问题。
这是一个异常(exception):
System.ComponentModel.Win32Exception (0x80004005): Permission denied
at Interop.Sys.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Int32& lpChildPid, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd)
at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at Ombi.Schedule.Jobs.Ombi.OmbiAutomaticUpdater.<Update>d__18.MoveNext() in C:\projects\requestplex\src\Ombi.Schedule\Jobs\Ombi\OmbiAutomaticUpdater.cs:line 218
这是代码:
var updaterFile = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location),
"TempUpdate", $"Ombi.Updater");
var start = new ProcessStartInfo
{
UseShellExecute = false,
CreateNoWindow = true,
FileName = updaterFile,
Arguments = GetArgs(settings), // This just gets some command line arguments for the app i am attempting to launch
WorkingDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "TempUpdate"),
};
using (var proc = new Process { StartInfo = start })
{
proc.Start();
}
当我们调用
.Start() 时似乎正在抛出异常.
我不确定为什么会这样,文件和文件夹的权限已设置为 777。
请您参考如下方法:
多年后,我遇到了同样的错误,并且不喜欢为此制作 .dll 可执行文件的方法。相反,将 FileName 设置为“dotnet”并将 dll 路径作为第一个参数传递就可以了。
var updaterFile = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location),
"TempUpdate", $"Ombi.Updater");
var start = new ProcessStartInfo
{
UseShellExecute = false,
CreateNoWindow = true,
FileName = "dotnet", // dotnet as executable
Arguments = updaterFile + " " +GetArgs(settings), // first argument as dll filepath
WorkingDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "TempUpdate"),
};
using (var proc = new Process { StartInfo = start })
{
proc.Start();
}




