24

I am facing the following issue when running my .Net Core application on Linux.

Here is the 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

Here is the code:

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();
}

It seems that the exception is being thrown when we call .Start().

I am not sure why this is happening, the permissions on the file and folders have been set to 777.

5
  • 1
    It's a self contained deployment
    – Jamie Rees
    Dec 13, 2017 at 12:03
  • 3
    If anyone needs help with this the last answer from this post helped me stackoverflow.com/questions/45132081/… May 24, 2019 at 15:11
  • Your .NET code looks fine. I would start by testing your code with some known built-in tool like "/bin/ping google.com" to confirm that the issue relates to ACLs. Also, check that all parent directories higher in the tree for Ombi. The updater has executive permissions. You may look for more information in Unix & Linux and Ask Ubuntu StackExchange sites. Jul 7, 2020 at 3:22
  • Maybe upload a tarball of it?
    – kettle
    Mar 22, 2021 at 4:31
  • Did you check your SELinux or whatever-you-have on your distribution? Shut it down just for a test and see if it'll work.
    – NewRK
    Jun 3, 2021 at 19:01

2 Answers 2

1

After years, I ran into same error and did not like approach of making .dll executable for this. Instead setting FileName to "dotnet" and passing dll path as first argument will do the trick.

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();
}
2
  • 2
    I guess this would have only worked if they have dotnet installed on the machine, if it's a self contained app, then this wouldn't work
    – Jamie Rees
    Aug 13, 2021 at 22:30
  • That's my dumbness. You're absolutely right. @JamieRees
    – Haldun
    Jan 4, 2022 at 10:59
0

A good diagnostic tool is to see if you can execute the file directly from the shell (in WSL if you're on Windows).

From a Windows perspective it's easy to forget that you need to mark your executables as executable on linux. If you can't execute it yourself, chmod 775 /your/file may help.

1
  • After the chmod command I could execute the file manually, but still not through Process.Start. I tried investigating using strace, although it didn't help , and eventually gave up. You can see strace output here: github.com/JeroenBos/JBSnorro.LayoutEngine/issues/17
    – JBSnorro
    Aug 15, 2021 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.