Hello!
I try to make scriptable application using Silverleght DLR. When I try execute JScript code witch cotains two or more lines of code, execution only first line. For example:
I had Compiled SL application written on ะก#.Main page contains Label named "lblMessage" and Button with Click event handler.
private void Button_Click(object sender, RoutedEventArgs e)
{
ScriptRuntime scriptRuntime = ScriptRuntime.Create();
foreach (string name in new string[] { "mscorlib", "System", "System.Windows", "System.Windows.Browser", "System.Net" })
{
scriptRuntime.LoadAssembly(scriptRuntime.Host.PlatformAdaptationLayer.LoadAssembly(name));
}
ScriptEngine scriptEngine = scriptRuntime.GetEngine("js");
ScriptScope baseScope = scriptEngine.CreateScope();
baseScope.SetVariable("lblMessage", lblMessage);
string script = "lblMessage.Content = 'First line of code';\rlblMessage.Content ='Second line of code';";
ScriptSource scriptSource = scriptEngine.CreateScriptSourceFromString(script);
CompiledCode compiledCode = scriptSource.Compile();
compiledCode.Execute(baseScope);
}
After execution Label.Text will be equal "First line of code" string.
Why ignored second line of code ?