[Ironruby-core] Using Local Variable in Silverlight

Aaron Clauson lists at ruby-forum.com
Mon Jul 14 07:50:13 EDT 2008

Hi All,

I'm getting an exception when I try and use the code snippet below in
Silverlight. The snippet works ok with a normal .Net app.

What I am trying to do is use a Ruby script running in my Silverlight
app to call a method that updates the text on a text block.

public delegate void LogMessageDelegate(string message);

public partial class Page : UserControl

  private void RunScript(object sender, System.Windows.RoutedEventArgs
    ScriptHelper scriptHelper = new ScriptHelper(WriteDebugMessage);

    ScriptScope scriptScope =
    scriptScope.SetVariable("sys", scriptHelper);
    scriptScope.Execute("sys.Log(\"hello world\")");

  private void WriteDebugMessage(string message)
    m_scriptDebugText.Text = message; // m_scriptDebugText is a text

public class ScriptHelper
  private event LogMessageDelegate m_logMessage;

  public ScriptHelper(LogMessageDelegate logMessage)
    m_logMessage = logMessage;

  public void Log(string message)

The exception I get back is:

System.Object, Ruby.Runtime.BlockParam, Microsoft.Scripting.SymbolId,

Is there a better approach to interacting between Silverlight UI
elements and the Ruby script? I'm not using any HTML as the whole
interface is built of SilverLight controls.


Posted via http://www.ruby-forum.com/.

More information about the Ironruby-core mailing list