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

Commented Unassigned: REngine.GetInstance fails [177]

$
0
0
Hi, I'm new to R but really would love to use it in my C# programs via RDotNet. I've added R.net via Manage NuGet Packages in VS2013 (RDotNet runtime Version v4.0.30319).

Within Windows 7 I'm running R-3.2.2 and both 32bit and 64bit reside within my C:\Program Files\R\R-3.2.2\bin folder.

Here's the beginning of my code.

using System.IO;
using System.Linq;
using RDotNet;
using RDotNet.NativeLibrary;

namespace RNetTest
{
class Program
{
static void Main(string[] args)
{
// Set the R_HOME environment variable in which R.dll is located.
Environment.SetEnvironmentVariable("R_HOME", @"C:\Program Files\R\R-3.2.2\bin\i386");

REngine engine = REngine.GetInstance("RDotNet");

It fails on the GetInstance with the error:

An unhandled exception of type 'System.ArgumentException' occurred in DynamicInterop.dll

Additional information: Could not retrieve a pointer for the symbol 'R_CStackLimit' in file 'RDotNet'

If I run REngine.GetInstance(); like is suggested I get the following error:

An unhandled exception of type 'System.Exception' occurred in DynamicInterop.dll

Additional information: This 32-bit process failed to load the library R.dll. Native error message is 'The system cannot find the file specified'

I've been wrestling with this for many hours now and finally asking for some help on what a solution might be. It should be noted the error is the same for 32bit or 64bit R.dll versions.


Comments: Thank you for that. I now think I know what is happening. Actually, this can be considered a bug, but there is a workaround. I'd advise you remove the R_HOME environment variable, if you can. This seems to be rather unusual to have is set system-wide anyway. Do not use `Environment.SetEnvironmentVariable` either. Just use `REngine.SetEnvironmentVariables()` and your setup should be found. Given your (our) programs run as 32 bits exes, provided your R keys in your Windows registry (regedit.exe, but be extra careful with accessing it) looks like the following (my setup, deliberately to default to 3.2.1 for previous tests, but yours can point to 3.2.2): ``` HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\R-core\R CurrentVersion 3.2.1 InstallPath c:\Program Files\R\R-3.2.1 subkeys of HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\R-core\R: ----> 3.2.1 ----> 3.2.2 ``` Then R.NET FindRPaths should report the following: ``` Is this process 64 bits? False Info: caller provided rPath=null, rHome=null Info: R.NET looked for preset R_HOME env. var. Found null Info: Found Windows registry key HKEY_LOCAL_MACHINE\SOFTWARE\R-core Info: Found Windows registry key HKEY_LOCAL_MACHINE\SOFTWARE\R-core Info: Found sub-key InstallPath under HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R Info: InstallPath value of key HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R: C:\ProgramFiles\R\R-3.2.1 Info: R.NET looked for platform-specific way (e.g. win registry). Found C:\Program Files\R\R-3.2.1 Info: R.NET trying to find rPath based on rHome; Deduced C:\Program Files\R\R-3.2.1\bin\i386 ``` Hope this helps - let us know either way. Thank you for helping to spot the issue.

Viewing all articles
Browse latest Browse all 1634

Trending Articles



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