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
e)
{
ScriptHelper scriptHelper = new ScriptHelper(WriteDebugMessage);
ScriptScope scriptScope =
IronRuby.CreateRuntime().CreateScope("IronRuby");
scriptScope.SetVariable("sys", scriptHelper);
scriptScope.Execute("sys.Log(\"hello world\")");
}
private void WriteDebugMessage(string message)
{
m_scriptDebugText.Text = message; // m_scriptDebugText is a text
block.
}
}
public class ScriptHelper
{
private event LogMessageDelegate m_logMessage;
public ScriptHelper(LogMessageDelegate logMessage)
{
m_logMessage = logMessage;
}
public void Log(string message)
{
m_logMessage(message);
}
}
The exception I get back is:
"Ruby.Runtime.RubyTopLevelScope.TopMethodMissing(Microsoft.Scripting.Runtime.CodeContext,
System.Object, Ruby.Runtime.BlockParam, Microsoft.Scripting.SymbolId,
System.Object[])"
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.
Regards,
Aaron
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core