Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

r

.net-core

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

like image 450
Philip Kendall Avatar asked May 12 '17 13:05

Philip Kendall


1 Answers

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.

like image 199
Bob Sammers Avatar answered Nov 17 '22 23:11

Bob Sammers