Quantcast
Channel: R.NET
Viewing all articles
Browse latest Browse all 1634

Commented Unassigned: SetEnvironmentVariables [128]

$
0
0
when i call REngine.SetEnvironmentVariables(); it throws an error:

Windows Registry sub-key 'R' of key 'HKEY_LOCAL_MACHINE\SOFTWARE\R-core' was not found

but actually, there is such a key in this folder.

i can find such lists in my registry.

HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R\3.0.1
HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R64\3.0.1


anyone can help me with this?

thanks in advance.
Comments: This is definitely odd. The code that throws this exception follows. The key for 'HKEY_LOCAL_MACHINE\SOFTWARE\R-core' is found, but opening the sub-key 'R' fails. The [OpenSubKey documentation](http://msdn.microsoft.com/en-us/library/vstudio/z9f66s0a(v=vs.100).aspx) is not exactly clear as to why null is returned, though related overloaded methods say null is returned if the sub-key is not found. No exception is thrown by OpenSubKey itself. In case this is because of your credentials (should not be for the needed read-only access), do you know which access level you have (e.g. Users, PowerUsers, Administrators)? As a workaround, you can specify the method parameters explicitely with something like: ``` C# bool is64Bit = Environment.Is64BitProcess; string archFolder = is64Bit ? @"\x64" : @"\i386"; REngine.SetEnvironmentVariables(rPath=@"c:\Program Files\R\R-3.1.0\bin" + archFolder, rHome=@"c:\Program Files\R\R-3.1.0); ``` ``` C# private static RegistryKey GetRCoreRegistryKeyWin32() { CheckPlatformWin32(); var rCore = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\R-core"); if (rCore == null) { rCore = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\R-core"); if (rCore == null) throw new ApplicationException("Windows Registry key 'SOFTWARE\\R-core' not found in HKEY_LOCAL_MACHINE nor HKEY_CURRENT_USER"); } bool is64Bit = Environment.Is64BitProcess; var subKey = is64Bit ? "R64" : "R"; var r = rCore.OpenSubKey(subKey); if (r == null) { throw new ApplicationException( string.Format( "Windows Registry sub-key '{0}' of key '{1}' was not found", subKey , rCore.ToString())); } return r; } ```

Viewing all articles
Browse latest Browse all 1634

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>