简体   繁体   中英

Using R.NET.Community in .NET Core 2.0 Preview 1

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();
        }
    }
}

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:

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.

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?

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 ).

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.

从NuGet获取最新的System.Security.Permissions在一个全新的2.1控制台应用程序中为我解决了这个问题。

Please check your dependencies. You still need to install R.Net R.Net . This will install the missing security files. I got the same error you received then I installed R.Net and the missing files and all is fine now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM