R Engine is not initializing

Nov 23, 2013 at 1:04 PM
Hi all.
I am new to R.NET so by following community discussions I tried to connect to R from C# using R.NET.
I have set correct dll path and it was fine.
but program is crashing while executing engine.Initialize();

My code is

static void Main(string[] args)

    var envPath = Environment.GetEnvironmentVariable("PATH");
    var rBinPath = @"C:\R-3.0.2\bin\i386";
    Environment.SetEnvironmentVariable("PATH", envPath + Path.PathSeparator + rBinPath);
    using (REngine engine = REngine.CreateInstance("RDotNet"))

        engine.Initialize(); // CRASHING IN THIS LINE.

        NumericVector group1 = engine.CreateNumericVector(new double[] { 30.02, 29.99, 30.11, 29.97, 30.01, 29.99 });
        engine.SetSymbol("group1", group1);
        NumericVector group2 = engine.Evaluate("group2 <- c(29.89, 29.93, 29.72, 29.98, 30.02, 29.98)").AsNumeric();

        // Test difference of mean and get the P-value.
        GenericVector testResult = engine.Evaluate("t.test(group1, group2)").AsList();
        double p = testResult["p.value"].AsNumeric().First();

        Console.WriteLine("Group1: [{0}]", string.Join(", ", group1));
        Console.WriteLine("Group2: [{0}]", string.Join(", ", group2));
        Console.WriteLine("P-value = {0:0.000}", p);

I am using
OS - XP sp3 -32 bit
R.NET -1.5.5
.NET 4.0
Visual Studio 2010

Please help me to solve this issue.
Nov 23, 2013 at 9:11 PM
Thanks for the precisions on the environment you are running in; a couple of additional questions:
Do you have a stack trace of the exception?
Also can you confirm you are running from a console application (it looks like it, just to confirm)
Nov 25, 2013 at 12:23 AM
Yes, I am running it from console.
its not throwing any exception. just crashing the program.
Nov 25, 2013 at 12:25 AM
hi ... Do i need to install IIS for this.........?
Nov 25, 2013 at 12:37 AM
Visual Studio should have a built-in web engine. Perhaps not the Express edition however. I can do 'F5' on the project from VS2012.
Nov 25, 2013 at 11:50 AM
Edited Nov 25, 2013 at 11:52 AM
HI Thanks for reply......
from last 2 days I was trying to run program as normal user.(It was crashing)

today as admin I reinstalled R and ran same program with changed dll path its running fine.
can any body explain what was the problem with normal user....... where as all other c# programs running fine with normal user.
Nov 25, 2013 at 7:30 PM
We can only assume that a non-admin install of R poses some problems to the R.NET initialization procedure. Without detailed error message this it hard to tell for sure.

Thanks for the report, testing for non-admin installs is desirable. Some corporate users may not have access to admin rights on company infrastructure, after all.