This project is read-only.

An exception of type 'RDotNet.ParseException' occurred in RDotNet.dll... Additional information: Error in the application.

Apr 2, 2014 at 7:56 AM

I am trying to execute R commands from my web application. But getting the exception message "An exception of type 'RDotNet.ParseException' occurred in RDotNet.dll". code is very straight forward and simple. Just copying the example-

protected void Page_Load(object sender, EventArgs e)

        // Set the folder in which R.dll locates.
        // See Documentation for automatic search of installation path.
        // This example set PATH environment variable for 64-bit process and R x64 on Windows.
        // You should appropriately set the correct location for other cases.
        // Refer to the Documentation page.
        var envPath = Environment.GetEnvironmentVariable("PATH");
        //var rBinPath = @"C:/Program Files/R/R-3.0.3/bin/i386";
        var rBinPath = @"C:\Program Files\R\R-3.0.3\bin;C:\Program Files\R\R-3.0.3\bin\i386;";
        Environment.SetEnvironmentVariable("PATH", envPath + Path.PathSeparator + rBinPath);

        // For Linux or Mac OS, R_HOME environment variable may be needed.
        //Environment.SetEnvironmentVariable("R_HOME", "/usr/lib/R")
        //REngine.SetDllDirectory(@"C:\Program Files\R\R-2.15.1\bin\i386");            
        using (REngine engine = REngine.CreateInstance("RDotNet"))
            // From v1.5, REngine requires explicit initialization.
            // You can set some parameters.

            foreach (string path in engine.Evaluate(".libPaths()").AsCharacter())

            // .NET Framework array to R vector.
            NumericVector group1 = engine.CreateNumericVector(new double[] { 30.02, 29.99, 30.11, 29.97, 30.01, 29.99 });
            engine.SetSymbol("group1", group1);
            // Direct parsing from R script.
            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);

            Response.Write("Group1: " + string.Join(", ", group1));
            Response.Write("Group2: " + string.Join(", ", group2));
            Response.Write("P-value =  " + p);

But the strange thing is that when I am executing this code in side main() method in console application I am not getting any exception or error. Everything works fine.

But when executing inside Page_Load() method, I am getting exception from the line

GenericVector testResult = engine.Evaluate("t.test(group1, group2)").AsList();

Can you help me to find the cause of the issue and how to resolve it.

Thanks in advance.
Apr 2, 2014 at 9:11 AM
I assume, second guessing from the method name, that you are running from ASP.NET.
Running R from ASP.NET is problematic, and is unlikely to be an issue in R.NET itself.
If you search for ASP.NET as a keyword in the dicussion tab, you will find more background.