1
Vote

Cannot correctly hit breakpoints in IronRuby hosted from C#

description

I have an IronRuby script hosted in a C# application in Visula Studio 2010. I set a breakpoint on a line of a class method in the script, but it would never be hit when debugging the code in VS. Is this a bug, or am I doing something wrong?
 
using System;
using System.Collections.Generic;
using IronRuby;
using IronRuby.Builtins;
using Microsoft.Scripting.Hosting;
 
namespace RubyInterOP
{
class Program
{
    public static void Main(string[] args)
    {
        var setup = new ScriptRuntimeSetup();
        setup.DebugMode = true;
        setup.AddRubySetup();
        var runtime = Ruby.CreateRuntime(setup);
 
        ScriptScope scope = null;
        ScriptEngine engine = null;
        engine = runtime.GetRubyEngine();
        scope = Ruby.CreateRuntime().CreateScope();
 
        ICollection<string> paths = new List<string>();
        paths.Add(@"C:\Users\tau\Documents\Visual Studio 2010\Projects\RubyInterOP\RubyInterOP");
        engine.SetSearchPaths(paths);
        engine.ExecuteFile(@"C:\Users\tau\Documents\Visual Studio 2010\Projects\RubyInterOP\RubyInterOP\Class1.rb");
        object rubyClass = engine.Runtime.Globals.GetVariable("Class1");
        object mainForm = engine.Operations.CreateInstance(rubyClass);
 
        engine.Operations.InvokeMember(mainForm, "ABC");
    }
}
}
 
Ruby file:
 
class Class1
def initialize()
end
def ABC()
    # add breakpoint here
    puts "ABC"
end
end

comments

smesser wrote Mar 21, 2012 at 5:55 AM

I may have had a similar issue. I opened a case with MS and they created hotfix for me.

If your issue is like mine. https://connect.microsoft.com/VisualStudio/feedback/details/651329/debugging-issue-with-vs-2010-sp1

If you can't see the info at the above link. If I remember correcly my issue was that IronRuby is compiled against .Net 4 and my application can't because of third party dependencies. Visual Studio calls the .Net 4 debugger for my .Net 3.5 code and no breakpoints are hit.

Here is a link to the hot fix if you are interested.

http://support.microsoft.com/kb/2591546

smesser wrote Mar 21, 2012 at 6:02 AM

PS: My comment assumes that you have VS SP1 installed