Quantcast
Channel: R.NET
Viewing all articles
Browse latest Browse all 1634

New Post: R.NET does not initialize at server

$
0
0
Hi R.NET expects,

I have a problem with R in my C# .NET web application project. R.NET works perfectly in my test machine, but when I move my application to server, R is not loading libraries or more likely just not initializing.

Server OS: Windows Server 2008 R2
R version: R-3.1.2
R.NET version: 1.5.16
framework: .NET Framework 4.5
web server: IIS7
test machine OS: Windows 7
Visual Studio 2012

I configure my web application for any CPU (32bit or 64bit). I added "C:\Program Files\R\R-3.1.2\bin\x64;C:\Program Files\R\R-3.1.2\bin\i386" to system variable PATH, as suggested in other posts.

Here is my Global.asax file, where I want the R.NET to be initialized.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using RDotNet;
using RDotNet.NativeLibrary;

namespace WebSite
{
    public class Global : System.Web.HttpApplication
    {
        public static REngine engine;

        protected void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup

            // set up enviromental path for R.dll      
            REngine.SetEnvironmentVariables();

            engine = REngine.GetInstance();

            // Initializes settings
            engine.Initialize();

            engine.Evaluate("library(Cairo);");
        }

        protected void Session_Start(object sender, EventArgs e)
        {
        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {
        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {
        }

        protected void Application_Error(object sender, EventArgs e)
        {
        }

        protected void Session_End(object sender, EventArgs e)
        {
        }

        protected void Application_End(object sender, EventArgs e)
        {
            //  Code that runs on application shutdown
            engine.Close();
            engine.Dispose();
        }
    }
}
When I start my application in IIS my website gives error as: "Error in library(Cairo): there is no package names Cairo". But I installed the package and are able to call the library function from R studio in my server. When I restart my website in IIS, it just do not respond anymore.

Could anyone be so kind to tell me why?? It works perfectly for local test! Anything I miss to do? Many thanks!

Viewing all articles
Browse latest Browse all 1634

Trending Articles