Monday, August 22, 2022

[FIXED] What is the difference between ProcessStartInfo.EnvironmentVariables and ProcessStartInfo.Environment

Issue

ProcessStartInfo.EnvironmentVariables:

A string dictionary that provides environment variables that apply to this process and child processes.

ProcessStartInfo.Environment:

A generic dictionary containing the environment variables that apply to this process and its child processes.

On .NET Framework applications, using the Environment property is the same as using the EnvironmentVariables property.

And on not .NET Framework applications, what is the difference between ProcessStartInfo.EnvironmentVariables and ProcessStartInfo.Environment?


Solution

They have different return types, but otherwise there is no functional difference.

According to this github issue, the .NET Core language designers wanted to use a standard IDictionary<> rather than the somewhat archaic StringDictionary used by the original EnvironmentVariables property. They couldn't change the return type of the existing property without breaking compatibility with .NET framework, so they added a new, mostly redundant, property.



Answered By - Darryl
Answer Checked By - Mary Flores (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.