Michele Michele - 2 months ago 12
R Question

SEHE Exception running R script with RDotNet

I'm getting the exception

'System.Runtime.InteropServices.SEHException' in RDotNet.dll

by running a simple R script:

n + minWidth

with this code in c#:

// Load the R environment
REngine engine = REngine.GetInstance();

// Load the input data
CharacterVector charVec = engine.CreateCharacterVector(new List<string> { csvFileName });
engine.SetSymbol("input", charVec);
engine.SetSymbol("n", engine.CreateNumeric(numberOfFanfolds));
engine.SetSymbol("minWidth", engine.CreateNumeric(minWidth));
engine.SetSymbol("minScrap", engine.CreateNumeric(minScrap));
engine.SetSymbol("cardboardStep", engine.CreateNumeric(cardboardStep));

// Run the script
results = await Task.Factory.StartNew(() => engine.Evaluate("source('" + script_file_ + "')"));

When i try to run the code directly it works correctly:

var results = await Task.Factory.StartNew(() => engine.Evaluate("n + minWidth"));

What does it means? What can I do? Do I need to format the R script in some way?


Just need to rearrange the file path

script_file_ = scriptFile.Replace("\\", "/");