在 .NET Core 2.0 Preview 1 中使用 R.NET.Community [英] Using R.NET.Community in .NET Core 2.0 Preview 1

查看:20
本文介绍了在 .NET Core 2.0 Preview 1 中使用 R.NET.Community的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来,我一直希望使用 R.NET.Community 在 .NET Core 应用程序中.很明显,尽管 NuGet 包尚未移植到 .NET Core,但这并不是一个开始.但是,随着 .NET Core 2.0 预览版 1 公告您可以从 .NET Core 引用 .NET Framework 库,我再次尝试:

For a while, I've been hoping to use R.NET.Community in a .NET Core app. Obviously though with the NuGet package not having been ported to .NET Core, that's been a non-starter. However, with the .NET Core 2.0 Preview 1 announcement that you can reference .NET Framework libraries from .NET Core, I gave this another go:

using RDotNet;

namespace RDotNetCore2
{
    class Program
    {
        static void Main(string[] args)
        {
            REngine.SetEnvironmentVariables();
            var engine = REngine.GetInstance();
        }
    }
}

在新的 Visual Studio 2017 Preview 中将其创建为 .NET Core 2.0 应用程序,这至少可以编译和运行,但在 GetInstance 调用中出错:

Creating this as a .NET Core 2.0 app in the new Visual Studio 2017 Preview, this at least gets as far as compiling and running, but errors at the GetInstance call:

无法加载文件或程序集System.Security.Permissions,版本=0.0.0.0,Culture=neutral,PublicKeyToken=cc7b13ffcd2ddd51".系统找不到指定的文件.

Could not load file or assembly 'System.Security.Permissions, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.

我能做些什么来解决这个问题,或者这只是 .NET Core 不支持的那些位之一(我怀疑这可能是因为 .NET Core 不支持 CAS)?

Is there anything I can do to fix this, or this just one of those bits which isn't supported in .NET Core (which I suspect may be likely due to the fact that CAS isn't supported on .NET Core)?

推荐答案

您确定这是框架 版本 的问题吗?

Are you sure this is a Framework version problem?

.net 4.x 版本中没有 System.Security.Permissions 文件(尽管有一个 命名空间).不过,在 .net Core 2.0 中有一个具有此名称的 dll(例如,包含 PrincipalPermissions 类.在 .net 4.7 中,该类在 mscorlib 中实现.dll).

There isn't a System.Security.Permissions file in the 4.x version of .net (although there is a namespace). There is a dll with this name in .net Core 2.0, though (containing, for example, the PrincipalPermissions class. In .net 4.7, this class is implemented in mscorlib.dll).

在您断定这行不通之前,可能值得查看一下您的项目参考资料.如果您可以在那里添加对 dll 的引用(大概您应该已经安装了 Core 2.0 运行时),这可能会解决问题.

It's probably worth having a look at your project references before you conclude that this isn't going to work. If you can add a reference there to the dll (which presumably you should have had installed with the Core 2.0 runtime), that might solve the problem.

这篇关于在 .NET Core 2.0 Preview 1 中使用 R.NET.Community的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆