2

Situation: I have installed R 3.3 and set up R for Visual Studio extension.

Code snippet:

 log.ir <- log(iris[, 1:4])
 ir.species <- iris[, 5]
 ir.pca <- stats:::prcomp(log.ir, center = TRUE, scale = TRUE)

This works in R interactive window in Visual Studio, it also work in RGui but when I run it using C# the code fails on 3rd line:

engine.Evaluate("log.ir <- log(iris[, 1:4])");
engine.Evaluate("ir.species <- iris[, 5]");
engine.Evaluate("ir.pca <- stats:::prcomp(log.ir, center = TRUE, scale = TRUE)");

Exception:

Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared object 'C:/Program Files/R/R-3.3.3/library/stats/libs/x64/stats.dll': LoadLibrary failure: The specified module could not be found.

Visual Studio error running R code

I have tried reinstalling all R components but it hasn't helped. And obviously I have checked and the stats.dll file exists in the path specified in the error.

RTVS version: enter image description here

Any help is much appreciated, Thanks

nlv
  • 791
  • 7
  • 28
  • Are you really using RTVS? If so could you post a screen shot of the About dialog box, scrolled down so we can see the RTVS (R Tools for Visual Studio) version, and the rest. – Mike Wise Mar 15 '17 at 18:17
  • @MikeWise updated the question with additional info. – nlv Mar 15 '17 at 19:09
  • So you are using rdotnet and RTVS both. Interesting. I had no idea rdotnet even existed :) – Mike Wise Mar 15 '17 at 19:13
  • RTVS is only a client for R. Rdotnet allows you to use it in C#... – nlv Mar 15 '17 at 19:16
  • Yes, I will look into it once I get something else finished. Probably be tomorrow. But you should mention that you have installed both of these R platforms in your "Situation:" above. I see them both in your tags, so that is okay. – Mike Wise Mar 15 '17 at 19:25
  • 1
    No problem. I kinda got this feeling its got to do with bit-ness, but not sure how because R and its libraries are 64bit – nlv Mar 15 '17 at 19:27

3 Answers3

1

I encountered this recently and the solution to this seems to be relatively straightforward. All you need to do is add the path to the R.dll from the relevant architecture (i386/x64)to the System Path statement. So, on my system I added "C:\Program Files\R\R-3.4.0\bin\i386" to the System Path Environment Variable. I also forced the architecture to x86, but that could just be overkill.

This information was gleaned from ASP.NET with R.NET

Michael Bond
  • 131
  • 3
1

I have been in same problem like you. I could not to load my base R dll functions. After two days of researching finally I found one question solving my problem:

https://github.com/jmp75/rdotnet/issues/62

Solution is very easy: in R-3.4.3 does not work properly reading path to your R folder, you can use R-3.4.2 and wait for correction in new R version :D - or rewrite R_Home environment variable.

RLesur
  • 5,810
  • 1
  • 18
  • 53
Milan Pračko
  • 33
  • 1
  • 6
-1

This was the correct solution for me after my computer crashed and I had to reload everything. Between the time I had developed 3 new programs and the time of the crash, R-3.4.3 came out and the new version did not work with my programs. I used the CRAN "Time Machine" and reinstalled an earlier version and everything worked just fine.

Waglio
  • 1
  • 1