Hello!
I try to make scriptable application using Silverlight DLR. When I try execute JScript code which contains 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();
gsFormManager fm = gsApplicationManager.FormManager;
baseScope.SetVariable("lblMessage", lblMessage);
string script = "lblMessage.Text = 'First line of code';\r\n" + "lblMessage.Text = '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 ?
Thank you.