调用从C#Ruby脚本 [英] Calling a ruby script from c#

查看:323
本文介绍了调用从C#Ruby脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人在这里找到答案调用C#

但运作的?我试过,但它一直以系统找不到指定文件的错误,我猜想它的失败,因为文件名前红宝石的命令,但我不能肯定。

感谢您的帮助

解决方案

您也可以尝试用执行红宝石code IronRuby的的像这样的东西

 使用系统;
使用Microsoft.Scripting.Hosting;
使用IronRuby的;

类ExecuteRubyExample
{
    静态无效的主要()
    {
        的ScriptEngine引擎= IronRuby.Ruby.CreateEngine();
        engine.ExecuteFile(C:/rubyscript.rb);
    }
}
 

It was answered here calling a ruby script in c#

but does that work? I tried this but it keeps failing with "The system cannot find the file specified" error, I'm assuming its because of ruby command before the file name, but I'm not quite sure.

Thanks for the help

解决方案

You could also try to execute the Ruby code with IronRuby with something like this

using System;
using Microsoft.Scripting.Hosting;
using IronRuby;

class ExecuteRubyExample
{
    static void Main()
    {
        ScriptEngine engine = IronRuby.Ruby.CreateEngine();
        engine.ExecuteFile("C:/rubyscript.rb");
    }
}

这篇关于调用从C#Ruby脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆