Silverlight: Solution to System.ExecutionEngineException

Posted on Wednesday, December 31, 2008

Today I ran into the charming System.ExecutionEngineException while trying to display a JavaScript alert using HtmlPage.Window.Alert(message). I was able to correlate the throwing of the exception to when I tried to display the alert in the handler of a KeyDown event leading me to suspect a threading issue. The solution I discovered was to asynchronously call the HtmlPage.Window.Alert method from the main thread using the Dispatcher.BeginInvoke() method. Specifically:
((Page)Application.Current.RootVisual).Dispatcher.BeginInvoke(new Action<String>(HtmlPage.Window.Alert), message);

Comments:
it works for me thank you
 

Post a Comment

Subscribe to Post Comments [Atom]





<< Home