Last post Feb 11, 2019 07:26 AM by porto___
Mar 21, 2018 06:14 AM|porto___|LINK
I'm encountering this issue with only
c# Environment.SetEnvironmentVariable(key,val, EnvironmentVariableTarget.Process) does not seem to set values that can be retrieved on the native-C app using getenv()
native-C app getenv() can read the values OK using Win2016 + VS-redist-2010
c# -> native-C app communication is through PInvoke (using SWIG),
and c# and native-C app runs in worker process in IIS.
This works fine in Windows Server 2012 and 2008 using VS-redist-2015
Any thought / suggestion will be appreciated.
ps. not sure which forum this question should be posted, so i posted it here.
Mar 22, 2018 09:05 AM|Brando ZWZ|LINK
According to your description, I guess the reason why you couldn't get the environment value is the native-C is not use the same process which the C# runs.
I suggest you could try to use below codes:
If you set this , the environment variable is stored or retrieved from the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment key in the Windows operating system registry.
Details, you could refer to below article.
Feb 11, 2019 07:26 AM|porto___|LINK
Thanks, it works, although not ideal.
As the application runs in IIS, the application pool needs elevated permission to execute
Might be easier if the environment variables is added under SYSTEM variable once.