R multiple version exists in a machine - The procedure entry point R_Cstackdir - error

Sep 24, 2014 at 11:33 AM
Hi -

We have one dot net application that uses Rdotnet Dlls and perfectly fine when R 3.0.2 installed in a machine.. The application was running smoothly.

Some days ago, one user installed R 3.1.1 in his machine , then application stopped running giving error

""The procedure entry point R_Cstackdir could not be located in the dynamic link library R.dll" with this call stack".

Since the user wants to use R 3.1.1 for his other purpose and our application is compatible with R 3.0.2,
1- is it possible that no matter which versions of R the user installs along with R 3.0.2 , the application should work??
2- Can we hadrdcode R 3.0.2 installation path in our dot net application so that the application stands still even other higher versions of R (like 3.1.0 , 3.1.1 etc) installed??


Sep 24, 2014 at 6:09 PM
Edited Sep 24, 2014 at 6:21 PM
I am able to reproduce the issue locally using the latest R.Net sources and R-3.0.2 by inappropriatly configuring R_HOME as a sytem environment variable.

1) If I do not set R_HOME, and I do not have any R folder paths in my system or user path (eg: C:\Program Files\R\R-3.0.2) then the application works correctly.
If I set R_HOME to a private path, such as C:\R\R-3.1.1\, the the R engine in the installed folder (R-3.0.2) attempts to load extension dlls from the C:\R\R-3.1.1 folder which is why the symbol for the stack direction cannot be found (CStackDir).

2) Yes, you can do this. Given I have an installed version of R-3.1.1 and a local build of R-3.0.2, I can cause R.Net to replace temporarily the default environment settings by using REngine.SetEnvironmentVariables as shown below.
class Program
    static void Main(string[] args)
        //Thi first argument puts the bin folder on the path and the second sets R_HOME
        REngine.SetEnvironmentVariables(@"C:\R\R-3.0.2\bin\i386", @"C:\R\R-3.0.2");
        using (var engine = REngine.GetInstance())

Sep 24, 2014 at 9:17 PM
Hi, The windows installer for R records the R_HOME of the version installed in the registry at HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R Change the entries here to reflect the version you wish to use with R.NET If you are running the 32-bit version of R on
a 64-bit OS, the registry entries need to be changed Here instead; HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\R-core\R This has been my experience.