Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the R.NET assembly in IronPython

Tags:

.net

r

ironpython

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!

like image 974
Wesley Avatar asked Jul 12 '11 17:07

Wesley


1 Answers

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.

like image 141
Jeff Hardy Avatar answered Sep 23 '22 13:09

Jeff Hardy