RDotNet.NativeLibrary.dll中发生了未处理的“System.ApplicationException”类型异常

时间:2015-10-16 16:05:08

标签: c# .net r interop

我正在研究使用R.NET在我的.NET应用程序中使用R库。 我已经安装了库和R环境。

但是,在运行项目页面上提供的示例程序时,我得到了上述异常:

 static void Main(string[] args)
        {

         //   REngine.SetEnvironmentVariables(); // <-- May be omitted; the next line would call it.
            REngine engine = REngine.GetInstance();
            // A somewhat contrived but customary Hello World:
            CharacterVector charVec = engine.CreateCharacterVector(new[] { "Hello, R world!, .NET speaking" });
            engine.SetSymbol("greetings", charVec);
            engine.Evaluate("str(greetings)"); // print out in the console
            string[] a = engine.Evaluate("'Hi there .NET, from the R engine'").AsCharacter().ToArray();
            Console.WriteLine("R answered: '{0}'", a[0]);
            Console.WriteLine("Press any key to exit the program");
            Console.ReadKey();
            engine.Dispose();
        }

如果有人遇到这个问题,我会很高兴收到任何评论。我搜索了相关的论坛,但没有运气。

完整的异常信息:

RDotNet.NativeLibrary.dll中发生未处理的“System.ApplicationException”类型异常 其他信息:在HKEY_LOCAL_MACHINE中找不到Windows注册表项“SOFTWARE \ R-core”,也没有在HKEY_CURRENT_USER中找到

我检查了R是否正确安装并且找到了R-Core HKEY_LOCAL_MACHINE

非常感谢提前

1 个答案:

答案 0 :(得分:3)

请按照jmp75.github.io/rdotnet/ts_paths_on_windows中的诊断说明进行操作。这有助于隔离问题。 我怀疑你的c#项目中的32位和64位不匹配,R设置(你安装了哪个R引擎:32位和/或64位?)但这只是一个疯狂的猜测而没有上述诊断

更改我的项目的目标平台解决了上述评论之后的问题