4

I'm trying to add IronPython to a .Net Core 1.0 web app, but having issues able to access the ScriptRuntime class. When I try to add using IronPython; I get errors saying that IronPython could not be found.

I also get errors about ScriptRuntime does not exist in the current context

Note: Currently using Visual Studio Code on OSX 10.11

The following are t of the dependencies and framework sections of my project.json:

{
  "version": "1.0.0-*",
  "dependencies": {
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "EntityFramework.Sqlite": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
    "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
    "Microsoft.Dnx.Runtime": "1.0.0-rc1-final",
    "Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
    "Microsoft.NETCore.Platforms": "1.0.1-*",
    "Newtonsoft.Json": "8.0.3",
    "IronPython": "2.7.5",
    "IronPython.StdLib": "2.7.5"
  },
  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel",
    "ef": "EntityFramework.Commands"
  },
  "frameworks": {
    "dnx451": {},
    "dnxcore50": {}
  },
}

And in my controller I have the following using statements:

using System.IO;
using System.Diagnostics;
using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc;
using Microsoft.Net.Http.Headers;
using Newtonsoft.Json.Linq;
using MatrixSynthesisWebApp.Models;
using System.Dynamic;
using System.Runtime.CompilerServices;
using IronPython;
denfromufa
  • 5,610
  • 13
  • 81
  • 138
mdeblois
  • 133
  • 2
  • 7
  • 3
    Given that the last IronPython release significantly predates the introduction of .net core this probably won't work without an IronPython build targeting .net core. – Simon Opelt May 22 '16 at 19:20

2 Answers2

3

Svicks answer is not the current state:

The IronPython-Team just released the beta of IronPython 2.7.8 supporting mono and .net core:

more infos here: https://github.com/IronLanguages/ironpython2/releases

IronPython 3 with support for mono and .net core is still in progress.

Matthias Burger
  • 5,549
  • 7
  • 49
  • 94
2

I believe it's not possible to use the IronPython NuGet package on .Net Core. That package is compiled for .Net Framework (and Silverlight), which means it's not usable from .Net Core.

You might consider requesting IronPython to be ported to netstandard, which is usable from .Net Core, on the project's Github site.

EDIT: It seems recent versions of the IronPython NuGet package support .Net Core 2.x. So it looks like this should work now.

svick
  • 236,525
  • 50
  • 385
  • 514