user2967150
user2967150

Reputation: 1

Running external libraries with R.net in IIS

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:

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?

Upvotes: 0

Views: 1430

Answers (2)

Gautam Vishwakarma
Gautam Vishwakarma

Reputation: 31

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.

Upvotes: 3

Milan Pračko
Milan Pračko

Reputation: 78

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?

Upvotes: 0

Related Questions