Attempted to read or write protected memory

Apr 22, 2012 at 9:24 PM

Hi! I have a problem. who can help me? I use RDotNet for create plot in file. I have error:

"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Listing of my programm:

RDotNet.REngine engine;
RDotNet.REngine.SetDllDirectory(@"C:\Program Files\R\R-2.12.0\bin\i386");
engine = RDotNet.REngine.GetInstanceFromID("RDotNet");
engine.EagerEvaluate("bmp(file='C:\\Users\\Алексей\\Desktop\\Тестовый файл.bmp'); plot.ts(rnorm(100))");  // error

How i can open memory for writing file? Thanks you.

Apr 28, 2012 at 3:01 AM


Thanks you for the succint code sample.

I cannot reproduce the problem with the current development codebase, using R 2.14.2 (Platform: x86_64-pc-mingw32/x64 (64-bit)
). I did not revert to the latest release as I suspect the issue will be hard to figure out even if I reproduce it. You may want to consider checking out the latest code if you can build it.

The following code worked fine:


var rdllloc = args.Length > 0 ? args[0] : @"c:\bin\R\R\bin\x64";
REngine.SetDllDirectory(rdllloc); // obsolete
var rhome = Environment.GetEnvironmentVariable("R_HOME");
if (string.IsNullOrEmpty(rhome)) Environment.SetEnvironmentVariable("R_HOME", @"c:\bin\R\R");
engine = REngine.CreateInstance("RDotNet");
engine = RDotNet.REngine.GetInstanceFromID("RDotNet");
engine.Evaluate("bmp(file='C:/Users/Public/Pictures/Sample Pictures/blah.bmp'); plot.ts(rnorm(100))");