-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
area-System.Diagnostics.Processneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsiderationIssue has been initially triaged, but needs deeper consideration or reconsideration
Milestone
Description
Description
Here's my code that I'm running with .NET Core 3.1 on Ubuntu Linux 20.04:
var psi = new ProcessStartInfo
{
FileName = fileName,
WorkingDirectory = "/",
UseShellExecute = false,
CreateNoWindow = true
};
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardInput = false;
using var process = Process.Start(startInfo);I get this exception:
- System.ArgumentNullException: String reference not set to an instance of a String. (Parameter 's')
at System.Text.Encoding.GetBytes(String s)
at Interop.Sys.AllocNullTerminatedArray(String[] arr, Byte**& arrPtr)
at Interop.Sys.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setUser, UInt32 userId, UInt32 groupId, UInt32[] groups, In>
at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setCredentials, UInt32 userId, UInt32 groupI>
at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at MyApp.Shared.Util.ProcessHelper.Execute(ProcessStartInfo startInfo, TimeSpan timeout, String stdin, CancellationToken cancellationToken) in (...)
...
I have no idea what Interop.Sys.AllocNullTerminatedArray is and where the source code of it can be inspected. .NET Core code finding is a challenge every time, especially since the search capabilities of GitHub are not worth mentioning and the full source code never even loads in Visual Studio on my computer.
So that method has some trouble when it gets null from somewhere and tries to pass it into Encoding.GetBytes. A null check must be added somewhere. You know where. I have no means to do that in my application. Until then, my task of running that external program cannot be accomplished with .NET.
Configuration
.NET Core SDK (reflecting any global.json):
Version: 3.1.402
Commit: 9b5de826fd
Runtime Environment:
OS Name: ubuntu
OS Version: 20.04
OS Platform: Linux
RID: ubuntu.20.04-x64
Base Path: /usr/share/dotnet/sdk/3.1.402/
Host (useful for support):
Version: 3.1.8
Commit: 9c1330dedd
.NET Core SDKs installed:
3.1.402 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
Metadata
Metadata
Assignees
Labels
area-System.Diagnostics.Processneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsiderationIssue has been initially triaged, but needs deeper consideration or reconsideration