5
votes

I would like to use the R statistical package for some data crunching in an IronPython 2.7 application. I have found the R.NET assembly, which should make this possible. The problem is that IronPython refuses to load the R.NET assembly.

The code:

import clr  
clr.AddReference("R.NET")

Produces:

System.IO.IOException: could not add reference to assembly R.NET

The assembly is located in a file called R.NET.dll, which is stored in the same folder from which I am invoking ipy.exe. I have checked that the folder is on sys.path. I have tried variations like clr.AddReference("R.NET.dll") and clr.AddReferenceToFile("R.NET.dll"). None are successful.

Could the problem be that there is a dot (.) in the assembly name? How would I work around that?

FWIW I am using Windows 7, R 2.13.0, IronPython 2.7, v4.0 of the .NET framework, and R.NET 1.4. I can successfully add a reference to R.NET from the Visual C# Express IDE (under .NET 4.0), and reproduce the examples from the R.NET homepage.

Thanks in advance!

1
Can you try clr.AddReferenceToFileAndPath? The . in the name shouldn't make a difference. - Jeff Hardy
clr.AddReferenceToFileAndPath returns: System.IO.IOException: file does not exist: C:\Users\wrbrooks\scratch\R.NET.dll. I assure you that the file does exist. I have tried specifying the path both with single slashes (`) and double slashes (\`). - Wesley
This problem seems to be cropping up elsewhere, too: IronPython forum post, and Another from the IronPython forums - Wesley
I tried clr.LoadAssemblyFromFile("R.NET.dll") and while it did not raise an exception, it also did not load the assembly (it returned a NoneType object, and import R.NET failed). - Wesley

1 Answers

6
votes

I'm going to guess that you use either Internet Explorer or Chrome, both of which mark downloaded files (with Zone.Identifier). .NET will refuse to load assemblies that are tainted with said mark.

To remove it, just unblock the R.NET.dll file. Now you should be good to go. I'll see if I can put in a better error message when trying to load such an assembly.