How to use Microsoft.Scripting.Hosting?
Asked Answered
D

4

9

To embed some IronPython Code into C# I want to use the ScriptEngine

using IronPython.Hosting;
using Microsoft.Scripting.Hosting;

I found the reference for IronPython, but where is the necessary reference for Scripting.Hosting? I can't find it within VisualStudio 2008, targeting .Net 3.5.

Dipper answered 5/11, 2009 at 14:45 Comment(0)
H
9

It looks like this is part of the DLR binaries ... more information here:

https://blogs.msdn.com/seshadripv/archive/2008/06/24/how-to-write-a-simple-dlr-host-in-c-using-hosting-api.aspx

Hassiehassin answered 5/11, 2009 at 15:16 Comment(0)
A
12

The DLR is actually broken into 2 parts: the "inner layer" which is included in .NET 4.0 and is part of System.Core.dll (and on downlevel platforms is available as Microsoft.Scripting.Core.dll) the "outer layer" which is available on CodePlex and ships w/ IronPython and IronRuby and is in Microsoft.Scripting.dll and Microsoft.Dynamic.dll. This part does not ship w/ .NET 4.0.

Artemus answered 5/11, 2009 at 18:37 Comment(0)
H
9

It looks like this is part of the DLR binaries ... more information here:

https://blogs.msdn.com/seshadripv/archive/2008/06/24/how-to-write-a-simple-dlr-host-in-c-using-hosting-api.aspx

Hassiehassin answered 5/11, 2009 at 15:16 Comment(0)
E
5

Microsoft.Scripting is part of the Dynamic Language Runtime. The Dynamic Language Runtime is part of .NET 4, IronPython and IronRuby and is also available standalone.

John Lam, the lead developer of IronRuby, created a little library called repl-lib, which implements a simple editor/REPL hybrid for IronRuby and IronPython which you can just drop into your application. In a blog post, John Lam demonstrates how he used repl-lib to add scripting to the Witty .NET Twitter client in 8(!) lines of code (plus 90 or so lines of XAML for the REPL UI and the REPL button).

That blog post is based on a presentation at TechEd 2009, which I unfortunately don't have access to, but if you do, you should check it out.

Be sure to also check out the forks of repl-lib, especially Jim Deville's.

Ettaettari answered 5/11, 2009 at 16:17 Comment(1)
That's fascinating. Thanks for summing this up.Dipper
C
2

I suggest that you use NuGet instead of managing the binaries yourself.

This worked for me. http://nuget.org/packages/DynamicLanguageRuntime.Net40.Unofficial

Cecilacecile answered 22/1, 2013 at 6:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.