R Installation prerequisite

Aug 5, 2013 at 7:21 AM
Hi,
This is a great project thank you very much.
I'm using RDotNet to embed R Capabilities to my existing C# Project. I'm working on Visual Studion 2010 and .NET 4.5 on a Windows 7.
I was using R.net with no problem. When i uninstall R from my computer it starts closing when running "engine.Initialize()". I have copied dll files to my project's application folder and add this address to PATH but it didn't worked.
I tried every directories in R instalation path. When I delete "library" folder, it starts to corrupt.
I have copied entire library folder to my application's path and set "R_LIBS" setting to this path but it didn't worked also.
I have searched source code for dependencies but couldn't find anything. Is R.Net uses some values from Registry or predefined R installation directory?
Should I install R to use R capabilities with R.Net?

Thanks in advance.
Coordinator
Aug 5, 2013 at 8:02 AM
StartupParameter passed to REngine is overwritten (at line 70 in CharacterDeviceAdapter.cs).
This is an obvious bug.

R_HOME variable (or set in StartupParameter.RHome) is assumed to be the installation path in the initialization process.
So putting the 'library' directory in the directory might work after the bug fix.

Thanks for the report.
Coordinator
Aug 5, 2013 at 8:17 AM
Fixed it now at changeset 60da7ea5523e.
Please try the newest source code.
Aug 5, 2013 at 10:32 AM
As i understand, there is no need to install R to use R functionality with R.NET anymore.
I have to copy dlls and library folder and set PATH and R_LIBS. Am i right?
Should i set R_HOME variable?
Aug 5, 2013 at 10:48 PM
Hi,
I have checked out the latest source code. Thanks for you quick action. Overriding problem is resolved.
But i cannot able to Run RDotNET seperated from R Installation. I have copied all the content of the R installation directory to my project path and set R_HOME to this path. I'm running some R Commands with no problem. When i try to load a csv file for second time it gives "AccessViolationException", i will give details of th Exception below.
When i install R version 3.0.1 and run the same code except seting R_HOME variable, it works fine.

System.AccessViolationException was unhandled
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=RDotNet
StackTrace:
   at RDotNet.Expression.TryEvaluate(REnvironment environment, SymbolicExpression& result) in C:\Users\testUser\Documents\Test Solution\Projects\TestProject\Test\RDotNet\R.NET\Expression.cs:line 58
   at RDotNet.REngine.Parse(String statement, StringBuilder incompleteStatement) in C:\Users\testUser\Documents\Test Solution\Projects\TestProject\Test\RDotNet\R.NET\REngine.cs:line 453
   at RDotNet.REngine.<Defer>d__0.MoveNext() in C:\Users\testUser\Documents\Test Solution\Projects\TestProject\Test\RDotNet\R.NET\REngine.cs:line 365
   at System.Linq.Enumerable.LastOrDefault[TSource](IEnumerable`1 source)
   at RDotNet.REngine.Evaluate(String statement) in C:\Users\testUser\Documents\Test Solution\Projects\TestProject\Test\RDotNet\R.NET\REngine.cs:line 324
   at TestProjectTool.Business.RWrapper.ExecuteCommand(String command) in C:\Users\testUser\Documents\Test Solution\Projects\TestProject\Test\TestProjectTool\Business\RWrapper.cs:line 76
   at TestProjectTool.GUI.FrmMain.btnRunModel_Click(Object sender, EventArgs e) in C:\Users\testUser\Documents\Test Solution\Projects\TestProject\Test\TestProjectTool\GUI\FrmMain.cs:line 217
   at TestProjectTool.GUI.FrmMain.btnAutoPilotMode_Click(Object sender, EventArgs e) in C:\Users\testUser\Documents\Test Solution\Projects\TestProject\Test\TestProjectTool\GUI\FrmMain.cs:line 291
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at TestProjectTool.Program.Main() in C:\Users\testUser\Documents\Test Solution\Projects\TestProject\Test\TestProjectTool\Program.cs:line 19
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Developer
Aug 6, 2013 at 1:20 AM
Hello,

Running R.NET on windows or Linux machines without a local R installation should be feasible. I have used R.NET (version 1.4, and R 2.15.x, but should still be feasible with more recent releases) in a cluster environment such that the cluster nodes running R.NET code were loading R libraries and its base packages from a shared directory.

From memory setting R_HOME was important, and you picked this up.

A priori running with R installed or not should have no bearing on the occurence of an "AccessViolationException". Do you have a small, self contained C# + R code reproducing the error?