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

An unhandled exception of type 'System.ApplicationException' occurred in RDotNet.NativeLibrary.dll

我正在考虑使用 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();
        }

如果有人对这个问题有 运行,我很乐意提出任何意见。我已经搜索了相关论坛,但还没有成功。

完整异常信息:

'System.ApplicationException' 类型的未处理异常发生在 RDotNet.NativeLibrary.dll 其他信息:Windows 注册表项 'SOFTWARE\R-core' 在 HKEY_LOCAL_MACHINE 和 HKEY_CURRENT_USER

中均未找到

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

非常感谢

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

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