When there is only one engine, loading a library is ok:
var engine = REngine.CreateInstance("RDotNet2");
engine.EagerEvaluate("library(lars)");
But when there are two or more engines, there will be an exception:
var engine = REngine.CreateInstance("RDotNet2");
var e2 = REngine.CreateInstance("Rll");
engine.EagerEvaluate("library(lars)");
the exception:
Error in library(lars) : no library trees found in 'lib.loc'
Unhandled Exception: RDotNet.ParseException: Error in the application.
at RDotNet.REngine.Parse(String statement, StringBuilder incompleteStatement)
in C:\Users\v-yizhu\Desktop\rdotnet_391c1b0c5b9a\R.NET\REngine.cs:line 534
at RDotNet.REngine.<Evaluate>d__0.MoveNext() in C:\Users\v-yizhu\Desktop\rdot
net_391c1b0c5b9a\R.NET\REngine.cs:line 444
at System.Linq.Enumerable.LastOrDefault[TSource](IEnumerable`1 source)
at RDotNet.REngine.EagerEvaluate(String statement) in C:\Users\v-yizhu\Deskto
p\rdotnet_391c1b0c5b9a\R.NET\REngine.cs:line 403
at CSTest.Program.Main(String[] args) in C:\Users\v-yizhu\Desktop\rdotnet_391
c1b0c5b9a\CSTest\Program.cs:line 38
Comments: I don't think this is feasible to launch several R engines in the same process. R is largely not multi-thread safe (mentioned in multilpe instances in the R-devel mailing list). The only reliable way would be to have inter-process communications. Something technically to consider, but unclear whether there is a point for R.NET to support this (need to assess benefits/drawbacks). Kosei may have a better understanding of the use cases and feasibility.
var engine = REngine.CreateInstance("RDotNet2");
engine.EagerEvaluate("library(lars)");
But when there are two or more engines, there will be an exception:
var engine = REngine.CreateInstance("RDotNet2");
var e2 = REngine.CreateInstance("Rll");
engine.EagerEvaluate("library(lars)");
the exception:
Error in library(lars) : no library trees found in 'lib.loc'
Unhandled Exception: RDotNet.ParseException: Error in the application.
at RDotNet.REngine.Parse(String statement, StringBuilder incompleteStatement)
in C:\Users\v-yizhu\Desktop\rdotnet_391c1b0c5b9a\R.NET\REngine.cs:line 534
at RDotNet.REngine.<Evaluate>d__0.MoveNext() in C:\Users\v-yizhu\Desktop\rdot
net_391c1b0c5b9a\R.NET\REngine.cs:line 444
at System.Linq.Enumerable.LastOrDefault[TSource](IEnumerable`1 source)
at RDotNet.REngine.EagerEvaluate(String statement) in C:\Users\v-yizhu\Deskto
p\rdotnet_391c1b0c5b9a\R.NET\REngine.cs:line 403
at CSTest.Program.Main(String[] args) in C:\Users\v-yizhu\Desktop\rdotnet_391
c1b0c5b9a\CSTest\Program.cs:line 38
Comments: I don't think this is feasible to launch several R engines in the same process. R is largely not multi-thread safe (mentioned in multilpe instances in the R-devel mailing list). The only reliable way would be to have inter-process communications. Something technically to consider, but unclear whether there is a point for R.NET to support this (need to assess benefits/drawbacks). Kosei may have a better understanding of the use cases and feasibility.