【问题标题】:DLR Scripting within Silverlight 4 ApplicationSilverlight 4 应用程序中的 DLR 脚本
【发布时间】:2010-09-25 19:13:01
【问题描述】:

我想为我正在开发的 Silverlight 4 应用程序添加一些脚本支持。我在装有 Visual Studio 2010 的机器上安装了 IronRuby 和 IronPython 的最新稳定版本。我查看了一些将 ScriptEngine 类与 IronRuby 和 IronPython 一起使用的示例。我什至让它在一个小型 Windows 窗体应用程序中工作,以确保我的代码正常工作。但是,我似乎无法将所需程序集/DLL 的引用添加到我的 Silverlight 4 应用程序中。

这是我的 ScriptEngine 代码:

ScriptEngine engine = Ruby.CreateEngine();
engine.Runtime.Globals.SetVariable("MainPage", this);
string code = "MainPage.txtTitle.Text = \"Hello from IronRuby!\"";
engine.Execute(code);

而且,这是我需要的 using 语句:

using IronRuby;
using Microsoft.Scripting.Hosting;

当我尝试从 IronRuby 1.0 版本添加对以下程序集/DLL 的引用时,Visual Studio 2010 不允许我添加它们并且没有提供关于原因的异常消息。结果我无法编译解决方案。

IronRuby.dll
IronRuby.Libraries.dll
IronRuby.Libraries.YAML.dll
Microsoft.Dynamic.dll
Microsoft.Scripting.Debugging.dll
Microsoft.Scripting.dll

我认为 Visual Studio 2010 不允许我添加程序集/DLL 的原因是因为它们是为 .NET 而不是 Silverlight 编译的。

有谁知道我在哪里可以获得这些程序集的 Silverlight 4 版本,或者我做错了什么?

任何帮助将不胜感激。谢谢!

【问题讨论】:

    标签: silverlight scripting ironpython ironruby dynamic-language-runtime


    【解决方案1】:

    IronRuby 1.0 和 IronPython 1.0 的 Silverlight 版本隐藏在 IronRuby 1.0 for .NET 2.0 SP1(Zip 存档)中,可从 http://ironruby.codeplex.com/releases 下载。在 zip 中查找 silverlight\bin。

    IronRuby 1.1 Silverlight 版本也可用。然而,Silverlight 的 IronPython 1.1 却无处可寻。 DLR 没有得到微软应得的爱,文档很少,二进制文件很难找到,IronRuby 和 IronPython 的未来看起来并不光明......

    【讨论】:

      【解决方案2】:

      只是对 Koen 的回答的一个注释:

      IronPython 2.6.x 中的 IronPython\Silverlight\bin .dll 是 .NET 3.5 二进制文件(在 Silverlight 4 中工作正常)。 Silverlight 4 的 .NET 4 二进制文件将与 IronPython 2.7 一起提供(当前位于 alpha)。

      【讨论】:

        【解决方案3】:

        我一直在寻找某种与 Silverlight 兼容的脚本引擎,经过数小时的研究,我找到了。我还没有测试,但我刚刚发现了一个名为 PaxScript.net 的项目,它支持 Silverlight 3/4/5。据作者介绍,您可以使用 VB.NET、C# 和 Delphi.NET 编写脚本。它确实生成字节码。我不知道为什么这个项目不为人所知,可能是缺乏“披露”。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2011-05-02
          • 2012-11-15
          • 1970-01-01
          • 2012-03-03
          • 1970-01-01
          • 2020-01-23
          • 1970-01-01
          相关资源
          最近更新 更多