StackOverflow in WCF caused by R.Net

0

Good Day,

i am trying to write an R code in .net to run as a WCF function. this function is suppose to import a csv file to MSSQL using R using .net code.

I am getting a stackoverflow error when i try to reference the odbc library over wcf, however if i try to run the function using debug instance it passes that point.

public string R_to_MSSQL_Server(string data, string Server, string Database,string Tablename)
    {
        StartupParameter rinit = new StartupParameter();
        rinit.Quiet = true;
        rinit.RHome = @"C:\Program Files\R\R-3.4.4\";
        rinit.Home = @"C:\R";
        REngine.SetEnvironmentVariables();
        REngine engine = REngine.GetInstance(null, true, rinit);
        StringBuilder Data = new StringBuilder();

        Data.Append(data);
        string filepath = Path.Combine(Path.GetTempPath(), "RTable.csv");
        //"UID= Tester;" +
        //"PWD= rstudioapi::askForPassword(\"password\"); " +
        try
        {
            UploadCSV(Data);

            filepath = PathCleaning(filepath);
            engine.Evaluate("Data <- read.csv(file<- '" + filepath + "', heade= TRUE, sep=',')");
            engine.Evaluate("Table <- data.frame(Data)");
            engine.Evaluate("connectionString <- ' " +
                            "driver={SQL Server}; " +
                            "server= "+ Server + "; " +
                            "database=" + Database + ";" +
                            "UID= Tester;" +
                            "PWD= rstudioapi::askForPassword(\"password\"); " +
                            "'");

            engine.Evaluate("library(odbc)");
            engine.Evaluate("library(healthcareai)");
            engine.Evaluate("con<- DBI::dbConnect(odbc::odbc(),.connection_string=connectionString)");
            engine.Evaluate("DBI::dbwriteTable(conn=con," + Tablename + " , Table)");

            return "Completed successfully";
        }
        catch( Exception x)
        {
            return "Fail to complete" + x;
        }
    }

the error when i run it through WCF hits at "engine.evaluate("library(odbc)");"

This is where its being called by another machine accessing it through wcf.

static void Main(string[] args)
    {
        MainServiceClient client = new MainServiceClient();

        string tablename = "Test Table";
        string Table = "";


        string Pkey ="Name";


        Table=File.ReadAllText(@"\\lonvmfs02\Home\kr.williams\TestTable2.csv");

        string query = client.R_to_MSSQL_Server(Table, "stage04", "CWDataSets", "Tester");

enter image description here

this is the error thats being thrown inside the WCF Machine ( W3wp debugging ).

System.StackOverflowException HResult=0x800703E9 Source= StackTrace:

this is all the exception details give.

how do it increase the size of the stack / get around this problem?

Thanks

c#
asp.net
r
wcf
asked on Stack Overflow Jan 3, 2019 by Kale Williams • edited Jan 3, 2019 by Kale Williams

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0