[Ironruby-core] Using Local Variable in Silverlight

Tomas Matousek Tomas.Matousek at microsoft.com
Mon Jul 14 12:17:03 EDT 2008

What's the exception type and message? Could you please file this as a bug?
It seems it should just work.


-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Aaron Clauson
Sent: Monday, July 14, 2008 4:50 AM
To: ironruby-core at rubyforge.org
Subject: [Ironruby-core] Using Local Variable in Silverlight

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/.
Ironruby-core mailing list
Ironruby-core at rubyforge.org

More information about the Ironruby-core mailing list