R.Net导致WCF中的StackOverflow

时间:2019-01-03 16:20:23

标签: c# asp.net r wcf

早安,

我正在尝试在.net中编写R代码以作为WCF函数运行。此功能假定使用.net代码使用R将csv文件导入到MSSQL。

当我尝试通过wcf引用odbc库时,我遇到了stackoverflow错误,但是,如果我尝试使用调试实例运行该函数,它将通过这一点。

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;
        }
    }

通过WCF运行该错误时,命中“ engine.evaluate(“ library(odbc)”);“

这是另一台通过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

这是在WCF计算机(W3wp调试)中引发的错误。

  

System.StackOverflowException     HResult = 0x800703E9     来源=     堆栈跟踪:   

这是所有例外情况细节给出的信息。

它如何增加堆栈的大小/解决这个问题?

谢谢

0 个答案:

没有答案