【问题标题】:IronRuby CreateScriptSourceFromFile can't find fileIronRuby CreateScriptSourceFromFile 找不到文件
【发布时间】:2012-02-09 03:48:06
【问题描述】:

我有一个非常简单的程序,旨在从 C# 调用 .rb 文件中的代码,但无法弄清楚如何正确形成 CreateScriptSourceFromFile 将接受的文件引用。这是最新的化身:

using System;
using System.Collections.Generic;
using System.IO;

using IronRuby;
using Microsoft.Scripting.Hosting;

namespace IronRubyFromCSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                var rubyEngine = Ruby.CreateEngine();
                var searchPaths = new List<String>();
                searchPaths.Add(".");
                searchPaths.Add(@"C:\sbgit\IRFromCS\IronRubyFromCSharp\Ruby\");
                rubyEngine.SetSearchPaths(searchPaths);

                var scriptSource = rubyEngine.CreateScriptSourceFromFile("hello.rb");
                var codeText = scriptSource.GetCode();
                Console.WriteLine(codeText);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            Console.ReadLine();
        }
    }
}

我已确认该文件存在并且它包含有效的 Ruby 代码,但每次执行此文件时,当我尝试执行、编译甚至只是访问代码时都会收到 System.NotImplementedException。

在 CreateScriptSourceFromFile 中引用代码文件的正确方法是什么?

【问题讨论】:

  • System.NotImplementedException 不是 System.IO.FileNotFoundException

标签: c# interop ironruby


【解决方案1】:

http://ironruby.codeplex.com/releases/view/60511#DownloadId=217152下载zip版本

使用 zip 版本的 dll(IronRuby.dll 和 Microsoft.Scripting.dll)

【讨论】:

  • 我不明白你在说什么。我已经安装了 IronRuby,这就是我使用的安装程序。
  • @Jekke 敢于先尝试,再谈。
猜你喜欢
  • 1970-01-01
  • 2021-12-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-09
相关资源
最近更新 更多