You can attach the VS debugger to your process, and as long as you've told the 
IronRuby engine to generate debug-able code, you can place breakpoints in Ruby 
code. The stack trace and watch windows are very verbose, as they show you the 
IronRuby internals, but with some extra digging around you can find the values 
of your variables and such.

You can initialize the IronRuby engine to generate debug-able code like this:

// Program.cs:
using IronRuby;
using Microsoft.Scripting.Hosting;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args) {
            // There might be a more concise way of doing it with 
Ruby.CreateEngine((ls) => {}), but I'm not sure 
            var setup = new ScriptRuntimeSetup() { DebugMode = true };
            setup.LanguageSetups.Add(Ruby.CreateRubySetup());
            var engine = Ruby.CreateRuntime(setup).GetRubyEngine();

            // place a breakpoint in foo.rb, and it'll break there
            engine.ExecuteFile("foo.rb");
        }
    }
}

# Foo.rb:
puts 'hi'

Note: don't create foo.rb in VS, as it'll a Unicode file, and IronRuby will 
give you a wonky exception like " undefined method `puts' for main:Object"

> -----Original Message-----
> From: ironruby-core-boun...@rubyforge.org [mailto:ironruby-core-
> boun...@rubyforge.org] On Behalf Of Santiago Molina
> Sent: Thursday, April 29, 2010 3:33 PM
> To: ironruby-core@rubyforge.org
> Subject: [Ironruby-core] Debugging ironruby code hosted by a c# app
> 
> I'm experimenting a little with ironruby and I just want to know if there's 
> any
> way to debug ironruby code that is hosted by a c# windows app. Any ideas?
> 
> thanks,
> Santiago
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core@rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core

_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

Reply via email to