English 中文(简体)
铁丝网
原标题:IronRuby CreateScriptSourceFromFile can t find file

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?

问题回答

download zip version from http://ironruby.codeplex.com/releases/view/60511#DownloadId=217152

使用齐p版本的批次(Iron Ruby.dll和Microsoft.forming.dll)





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签