This project is read-only.

Restarting R in a server application

Oct 2, 2015 at 3:10 PM
I am developing a C# solution to run (version 1.6.5) on a Windows server 2008 R2. The R functionality runs pretty stable and performs well. My Problem is that the server is running constantly, but R won't be needed all the time so in order to keep the maintenance simple I’d like to implement a Routine that starts the REngine , runs the R code and then shuts the REngine down again, so it can later be restarted. To shut down/idle the REngine temporarily the function Dispose() seems not to be appropriate as is prevents the REngine from restarting again. However the Rdotnet documentation also recommends to always shutdown an engine after using it. I tried using Dispose() but got different exeptions, in different usage cases one of them is:
The single REngine instance has already been disposed of (i.e. shut down). Multiple engine restart is not possible.
My R initialization in C# currently looks like this:
  class RDotNetAdaptor {
  protected REngine REngine;
  protected RDotNetAdaptor() {
     REngine = REngine.GetInstance();
  ~RDotNetAdaptor() {
How can I shut down/ idle the REngine so I can restart it again later?
Oct 9, 2015 at 10:07 PM
R.NET embeds R in the same process as the main program, and R cannot be restarted twice in the same process. This is a limit of R, not R.NET.

A solution to this has been developed on a branch of the codebase, but I have not had the resources to bring it to a testing/release phase yet (not aligned with my day work needs)