Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R.Net 1.9.0 does not seem to work with .Net 5.0 #147

Open
UnclAlDeveloper opened this issue Oct 11, 2021 · 13 comments
Open

R.Net 1.9.0 does not seem to work with .Net 5.0 #147

UnclAlDeveloper opened this issue Oct 11, 2021 · 13 comments

Comments

@UnclAlDeveloper
Copy link

I'm looking to upgrade my C# applications to .Net 5.0. One of the breaking points is that R.Net doesn't seem to work with .Net 5.0. I receive the following error when calling REngine.GetInstance():

Unhandled exception at 0x00007FF8C76B0D10 (msvcrt.dll) in TestAndDevelopment2Console.exe: RangeChecks instrumentation code detected an out of range array access.

@fmaillet
Copy link

fmaillet commented Jan 9, 2022

Same problem with .Net 6 : I already developed a C# .Net 4.8 framework Winform program using R.Net (Nuget package 1.9.0 with R 4.1.2 installed) and this one is working fine. Completely rewritten with .Net 6, and program crash with 3221226505 error code (Stack buffer overflow / overrun) when calling REngine.GetInstance().

@rolfans
Copy link

rolfans commented Feb 17, 2022

Does anyone have a solution for how to make it work with .net 6? Am struggeling to find the problem.

@lrasmus
Copy link
Contributor

lrasmus commented Feb 25, 2022

I tried to reproduce this but didn't get a crash. I'm wondering if any of you have a code repo you could point me to that is failing that I could test with?

My attempt was a really basic console app, using .NET 6 on Windows 10:

using RDotNet;

REngine.SetEnvironmentVariables();
using (var engine = REngine.GetInstance())
{
    Console.WriteLine(engine.DllVersion);
    var result = engine.Evaluate("a = 10");
    result = engine.Evaluate("a");
    var a = result.AsNumeric();
    Console.WriteLine(a[0]);
}

Produces

4.0.2
10

C:\Users\Luke\source\repos\ConsoleApp2\ConsoleApp2\bin\Debug\net6.0\ConsoleApp2.exe (process 10128) exited with code 0.

@rolfans
Copy link

rolfans commented Mar 2, 2022

in x64 with built with .net 6: have tried to debug, and it now fails in the CreateInstance() with the following error message: "This 64-bit process failed to load the library R.dll. Native error message is 'The operation completed successfully.'" It looks to be failing inside DynamicInterop 0.9.1
Before I tried to debug it, it crashed at Initialize(): GetFunction<setup_Rmainloop>()();

@fmaillet
Copy link

fmaillet commented Mar 6, 2022

Quite the same thing as Irasmus with a simple console app, using .NET 6 and Windows 10 at first, and now Windows 11 :

`using RDotNet;

Console.WriteLine("Hello, World!");

RDotNet.StartupParameter param = new StartupParameter();
param.Interactive = true; //?
param.Quiet = true; //n'affiche rien sur la console

// by default: string dll = null, bool initialize = true, StartupParameter parameter = null, ICharacterDevice device = null
REngine engine = REngine.GetInstance(null, true, param, null);

// by default: StartupParameter parameter = null, ICharacterDevice device = null, bool setupMainLoop = true
engine.Initialize(param, null, true);

Console.ReadKey();
`

Produces :

The program '[33040] RDotNet_Test6_ConsoleApp.exe' has exited with code 3221226505 (0xc0000409).

Seems that it is the engine.Initialize that fails.

@lrasmus
Copy link
Contributor

lrasmus commented Mar 7, 2022

@rolfans - thanks for the update, what version of R are you using?
@fmaillet - thank you for the update as well, also curious about R version.

thanks!

@rolfans
Copy link

rolfans commented Mar 8, 2022

I am using R 4.1.1, and it worked with rdotnet 1.9 on .net 4.8

@fmaillet
Copy link

fmaillet commented Mar 8, 2022

I'm using R 4.1.2.
As Rolfans, all is working fine with R.Net 1.9.0 within a .Net Framework 4.8.
I want to upgrade to WPF .Net 6.0, and this is where R.Net crashes :(

@JD-Robbs
Copy link

JD-Robbs commented Mar 9, 2022

Not sure if this is related, but I am using .Net 6.0.0, R 4.0.5 and the latest R.Net on Windows 10.

My app (WPF) crashes when it calls REngine.GetInstance() with the following code:

The program '[27784] MYAPP.exe' has exited with code 3221226505 (0xc0000409).

@rolfans
Copy link

rolfans commented Mar 14, 2022

Think I found the error: https://github.com/rdotnet/dynamic-interop-dll needs to be built for .net 6 as well. Have not made it work yet, but hope that will be fixed fast now.

@rolfans
Copy link

rolfans commented Mar 15, 2022

Was a bit quick yesterday, that did not work, the problem is: in dynamic-interop: var handle = Win32.LoadLibrary(filename); that will not load the dll, even when the path is hardcoded.

@rolfans
Copy link

rolfans commented May 20, 2022

No one has made rdotnet work with .net 5 or 6? I gave up and hoped someone That knows the library would find the issue.

@tmcintee
Copy link

I have verified that, on my machine:

  • The sample code above by @Irasmus does not work for .NET 5.0 or .NET 6.0 with R v4.1.2 and Nuget v1.9 or v1.7.
  • It does work with .NET 5.0 and .NET 6.0 with R v4.0.2 and Nuget v1.9

Since I can get away with just using whichever version of R I want, I'll be doing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants