Silverlight: Solution to System.ExecutionEngineException
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);
# posted by Greg @ 12/31/2008 11:14:00 PM
Post a Comment