R 3.1.0 and RDotNet_1.5.10 dll but the REngine does not start

Sep 18, 2014 at 9:48 AM
Edited Sep 18, 2014 at 11:39 AM
Hi -

I have R 3.1.0 version installed in my machine and i have added RDotNet_1.5.10 ( dlls) into the solution. I have visual studio 2010 installed.

I tried a simple program to run
           REngine engine = REngine.GetInstance();
            engine.Initialize();
            // A somewhat contrived but customary Hello World:
            CharacterVector charVec = engine.CreateCharacterVector(new[] { "Hello, R world!, .NET speaking" });
            engine.SetSymbol("greetings", charVec);
            engine.Evaluate("str(greetings)"); // print out in the console
            string[] a = engine.Evaluate("'Hi there .NET, from the R engine'").AsCharacter().ToArray();
            Console.WriteLine("R answered: '{0}'", a[0]);
            Console.WriteLine("Press any key to exit the program");
            Console.ReadKey();
            engine.Dispose();

Error message - The procedure entry point R_Cstackdir could not be located in the dynamic link library R.dll




Can anybody tell us how to make it work.

Thanks,

Suryansu
Developer
Sep 18, 2014 at 10:21 PM
Two questions:

Do you have a details of the call stack given by the exception I assume is being thrown?
Are you sure this is "R_Cstackdir" reported as a missing entry point, and not rather "R_CStackLimit"?

I also recommend you use the the latest release at the R.NET nuget page
Sep 19, 2014 at 6:09 AM
Edited Sep 19, 2014 at 7:00 AM
Here is the details call stack

at RDotNet.REngine.Parse(String statement, StringBuilder incompleteStatement)
at RDotNet.REngine.<Defer>c__Iterator4.MoveNext()
at System.Linq.Enumerable.LastOrDefault[TSource](IEnumerable`1 source)
at RDotNet.REngine.Evaluate(String statement)
at R_Process.Program.Main(String[] args) in C:\SNACN\SNACN_Code\17thSep2014\SNACN\R Process\Program.cs:line 83


I confirm that it is "R_Cstackdir" .

When i tried via R.net Nuget -- I am still getting __"The procedure entry point R_Cstackdir could not be located in the dynamic link library R.dll" with this call stack



at RDotNet.REngine.Parse(String statement, StringBuilder incompleteStatement)
at RDotNet.REngine.<Defer>d__0.MoveNext()
at System.Linq.Enumerable.LastOrDefault[TSource](IEnumerable`1 source)
at RDotNet.REngine.Evaluate(String statement)
at RDotNet.REngine.Initialize(StartupParameter parameter, ICharacterDevice device, Boolean setupMainLoop)
at RDotNet.REngine.GetInstance(String dll, Boolean initialize, StartupParameter parameter, ICharacterDevice device)
at R_Process.Program.Main(String[] args) in C:\SNACN\SNACN_Code\17thSep2014\SNACN\R Process\Program.cs:line 25
Developer
Sep 19, 2014 at 8:39 AM
This is odd, really odd.

I tried the sample program you use with R.NET 1.5.10, both process types (64 and 32 bits) work just file. I have R 3.1.0 running on Win7 64 bits with the latest patches.

Thanks to the very useful tool CFF Explorer (my thanks to the author) I can check that indeed R_CStackDir is defined and exported. But R.NET does not try to access it (it does touch R_CStackLimit however). See image at the end.

Can you check out the latest onboarding guide? I just updated it to reference the latest public R.NET packages. I do not get any issues either. It is the best I can propose, in the hope the issue is gone for you. If indeed "something" tries to access R_Cstackdir with that capitalization (instead of R_CStackDir) then yes, there is a problem. But I have no idea what does and why this happens.

R.dll export table
Sep 19, 2014 at 10:17 AM
Edited Sep 19, 2014 at 10:29 AM
hello, tried a new sample console program(hello world) from latest onboarding guide. I have windows 8 with R.dotnet of 1.5.16 dll version that is referenced via nugget and R 3.1.0 installed in my system.

Code snippet
   using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RDotNet;
using RDotNet.NativeLibrary;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace helloworld
{
class Program
{
    static void Main(string[] args)
    {
        REngine.SetEnvironmentVariables(); // <-- May be omitted; next line would call it. 
      REngine engine = REngine.GetInstance(); 
      // A somewhat contrived but customary Hello World: 
      CharacterVector charVec = engine.CreateCharacterVector(new[] { "Hello, R world!, .NET speaking" }); 
      engine.SetSymbol("greetings", charVec); 
      engine.Evaluate("str(greetings)"); // print out in the console 
      string[] a = engine.Evaluate("'Hi there .NET, from the R engine'").AsCharacter().ToArray(); 
      Console.WriteLine("R answered: '{0}'", a[0]); 
      Console.WriteLine("Press any key to exit the program"); 
      Console.ReadKey(); 
      engine.Dispose(); 


    }
}
}

I am still get the same error message. I am unable to paste/attach a screenhsot here..

"The procedure entry point R_Cstackdir could not be located in the dynamic link library R.dll" with this call stack"
Sep 19, 2014 at 11:47 AM
Interesting point is I used CFF Explorer and could see the R_CStacklimit...But R_CStackdir is not defined.

strange... I am unable to share the screenshot..If possible, can I get your mailed?
Developer
Sep 20, 2014 at 12:41 AM
At least the behavior has a diagnosed root cause that is consistent with the symptoms and error reported. This remains baffling as presumably we would have installed R 3.1.0 from the very same installer on CRAN and its mirrors. Or did you compile it from source using RTools? The latter would point to an issue that needs reporting as a bug to the R community.

The best option I can suggest is to uninstall R, and install the latest (3.1.1, from memory) and see whether the issue just goes away.

Thanks for investigating the issue in quite some depth on your machine; this really helps to move forwards.
Sep 22, 2014 at 5:13 PM
Edited Sep 22, 2014 at 5:13 PM
A good next step is to try it in RStudio using your installed version of R. If its broken in RStudio, its a problem with the R build you are using .

Using RStudio, you can use the "Cstack_info()" function to doublecheck the Cstack information.

It is impossible for a working copy of R to not have this symbol defined as it is part of the initialization routines. For windows, the relavent portion of initialization code comes from src/gnuwin32/system.c:R_SetWin32
...elided...
R_CStackStart = top;
R_CStackLimit = top - bottom;
}

R_CStackDir = 1;
R_Home = Rp->rhome;
if(strlen(R_Home) >= MAX_PATH) R_Suicide("Invalid R_HOME");
...elided...