0

We're trying to run R.net from an ASP.Net webpage in IIS, but encounter the problem that the R engine can't access external libraries. I know this is a common problem, but the typical solutions haven't worked when it comes to IIS (only IIS express from inside VS).

For example, when trying to use 'colorRampPalette' in R which relies on a DLL, the following error message appears:

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

It is not the stats.dll that is the problem, but rather another DLL it references.

Now, using the function in R works fine. Using the function from R.net in VS debugging works fine. However, running it from IIS does not work. Normally, it's just a path variable missing to get it to work, but this doesn't seem to be the case here.

What we've tried:

  • Ensured that the PATH variable has the necessary folders (i.e. C:\Program Files\R\R-3.4.3\bin\x64 etc). If this was wrong then R.net wouldn't work locally, and I've also verified that IIS doesn't reset the PATH variables which has been pointed out in other sources. When I check the PATH variable from inside IIS the necessary folders are listed.
  • Checked that the library, home and bin path in R.net is correct when running under IIS.
  • Ensured that the IIS_IUSRS user has read/write access to the necessary folders and files.
  • Verified that the R code is correct.

It seems that this is a common problem, but most solutions refer to making sure the PATH variable is correct, which simply isn't enough in this case.

We're running (Amazon web service): Windows Server 2016 x64, IIS 10, R.NET 1.7, C# 4.5.2, R 3.4.2

I've also tried on another (non-AWS) server with a similar setup.

Any ideas of what can cause this? Since a lot of people have issues with R.Net and IIS I suspect someone encountered the same problem where the PATH variable wasn't enough?

2 Answers 2

3

As mentioned by user2967150, It is not the stats.dll that is the problem, but rather another DLL it references. After doing lot of research I found that It try to find Rlapack.dll in 'C:/Program Files/R/R-3.4.2/library/stats/libs/x64/ path. so you just have to copy Rlapack.dll from 'C:\Program Files\R\R-3.4.4\bin\x64 \Rlapack.dll' to 'C:/Program Files/R/R-3.4.2/library/stats/libs/x64/ . After this the web Application can access external R libraries.

Note: I assume that your web Application Run locally but creates a problem when you try to run it on IIS.

1
  • you.have.saved.my.day - hours trying to figure out why it worked in console app but not in a web app such as MVC - will investigate further why this occurs May 25, 2020 at 21:02
0

I was solving same issue. For IIS I did not find the solution. I was also debugging the R.NET code, but solution by setting correct path to R folder did not work.

The solution is created additional layer, which cover running R project (actually create own R server). I used self hosted WCF service,

https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-host-a-wcf-service-in-a-managed-windows-service

which is practically console application and has benefits application running not in IIS application pool. This solution also cover singleton REngine problem. In case you run the instance or REngine in IIS, there is no posibility dispose it, only by stop application pool. For self-hosted service you can set trigger for restarting application in case memory leak.

During this implementation I discover problem run R.NET again R 3.4.3 in debug mode on console application I get error "The library "..." could not be load", so I used the R 3.4.2. which work nice. 86x installation is required - independent the your application run in 64x/ANYCPU environment.

Have you found any other solution for that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.