This project is read-only.

Unable to use latest R in VS2013 Win 8.1 x64 .NET 4.0 => x64, WinForms project

Nov 13, 2014 at 12:21 PM
Edited Nov 13, 2014 at 12:51 PM
R installed using NuGet in VS 2013 without error. RDotNet and RDotNet.NativeLibrary references added to project as expected.

ErrorL "An unhandled exception of type 'System.ApplicationException' occurred in RDotNet.NativeLibrary.dll Additional information: Windows Registry key 'SOFTWARE\R-core' not found in HKEY_LOCAL_MACHINE nor HKEY_CURRENT_USER"
using RDotNet;

// crashes on first line:
// the following usages produce a Directory not found exception:
// also crashes if this is used: path to Desktop omitted
// REngine.SetEnvironmentVariables(@"...\Nov12UseR\Nov12UseR\bin\Debug\RDotNet.dll"); // // // also crashes if this is used: path to Desktop omitted
// REngine.SetEnvironmentVariables(@"...\Nov12UseR\packages\R.NET.Community.1.5.16\RDotNet.dll");
        engine = REngine.GetInstance();
        if (engine.IsRunning == false)
My research on StackOverFlow and here has turned up no solution, but it is obvious this is a frequent problem.

thanks, Bill
Nov 13, 2014 at 1:00 PM
issue 128, for which detailed explanation and fixes are provided.

In trying to specify rPath explicitely, You are providinng the path to RDotNet.dll to the method. rPath should be the directory where the native R.dll is, not RDotNet.dll.
Nov 13, 2014 at 1:09 PM
Edited Nov 13, 2014 at 1:54 PM
Hi, thanks for your prompt reply.

I moved to trying to specify the file-path explicitly ... only as a "last resort" ... because the expected behavior after the package install via Nuget: that one could invoke REngine.SetEnvironmentVariables(); with no argument does not work.


Note that I read "issue 128" before I installed R: in fact, a comment there was useful in deciding which of the two choices for R.NET in Visual Studio Gallery to install.

I've examined the source of R's 'CreateInstance method: I notice a use of "R.dll" : you also mentioned that: on this machine there is no R.dll.

Setting the filepath used as an argument to 'SetEnvironmentVariables to the _directories ... not the .dll ... that contain the RDotNet.dll does not work: the same missing Registry Key error is thrown reported in my first post.

On my system the RDotNet.dll and other dll's are in two places:
  1. in the project folder path shown in my original post
  2. in a temp folder created by NuGet:
C:\Users... redacted ...\AppData\Local\Temp\nuget\R.NET.Community.1.5.16\lib\net40
Nov 13, 2014 at 4:51 PM
It seems like you don't have R installed? The registry entry and R_HOME environment variable are set by the R installer.
Nov 14, 2014 at 6:57 AM
Thanks for your response ! Indeed, the NuGet install from VS 2013 did not install 'R.dll.

Is there something wrong with the NuGet install ?

thanks, Bill
Nov 14, 2014 at 8:25 AM
As mentioned in the documentation, "R.NET requires .NET Framework 4 and the native R DLLs installed with the R environment". You have to have R already installed on your machine, or at least have a working R folder hierarchy reachable.

Nothing wrong with the NuGet packages; users have complete control of their R software with or without R.NET, but this is their responsibility to install this prerequisite.
Nov 14, 2014 at 11:45 AM
You should go to the R project homepage to install a version of R on windows.

While you should then be able to run the few R.NET introductory tutorials, I suggest you to learn a bit about R itself, before accessing it via R.NET. R.NET is certainly no t a substitute for learning R.