我只遇到这个问题
- Windows Server 2016 (Win2016) 和
- VisualStudio-可再发行 2015 (VS-redist-2015 = msvcp14)
c# Environment.SetEnvironmentVariable(key,val, EnvironmentVariableTarget.Process)
似乎没有设置可以使用 getenv() 在 native C 应用程序上检索的值
原生 C 应用 getenv()可以使用 Win2016 + VS-redist-2010 读取值 OK
这在使用 VS-redist-2015 的 Windows Server 2012 和 2008 中运行良好
任何想法/建议将不胜感激。
最佳答案
默认Environment.SetEnvironmentVariable(string <variable>, string <value>)
存储当前进程的变量。为了更加确定,您需要使用包含目标 Environment.SetEnvironmentVariable(string <variable>, string <value>, EnvironmentVariableTarget <target>)
的重载。这样你就可以将目标设置为 Machine
或User
.
关于c# - Environment.SetEnvironmentVariable 未设置任何值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49398367/