I have a very simple program that is meant to call the code in an .rb file from C#, but can t figure out how to properly form a file reference that CreateScriptSourceFromFile will accept. Here is the most current incarnation:
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:sbgitIRFromCSIronRubyFromCSharpRuby");
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();
}
}
}
我已经确认,档案已经存在,其中载有有效的《鲁比法典》,但每次我执行时,我都会有一个系统。 未执行 在我试图执行、编纂或甚至仅仅查阅守则时,例外。
What is the proper way to reference a code file in CreateScriptSourceFromFile?