예제 #1
0
        public void OnXmlHttpDownloadComplete(ScriptObject handlerThis, string file)
        {
            try {
                object objReadyState = handlerThis.GetProperty("readyState");
                object objStatus     = handlerThis.GetProperty("status");

                int readyState = 0;
                int status     = 0;

                if (objStatus != null)
                {
                    status = (int)((double)objStatus / 1);
                }
                if (objReadyState != null)
                {
                    readyState = (int)((double)objReadyState / 1);
                }

                if (readyState == 4 && status == 200)
                {
                    string content = (string)handlerThis.GetProperty("responseText");
                    DownloadComplete(new Uri(file, UriKind.RelativeOrAbsolute), content, _onComplete);
                }
                else if (readyState == 4 && status != 200)
                {
                    throw new Exception(file + " download failed (status: " + status + ")");
                }
            } catch (Exception e) {
                // This catch-all is necessary since any unhandled exceptions
                if (Settings.ReportUnhandledErrors)
                {
                    ErrorFormatter.DisplayError(Settings.ErrorTargetID, e);
                }
            }
        }
 /// <summary>
 /// Any unhandled exceptions in the Silverlight application will be
 /// handled here, which displays the error to the HTML page hosting the
 /// Silverlight control.
 /// </summary>
 internal void OnUnhandledException(object sender, ApplicationUnhandledExceptionEventArgs args)
 {
     args.Handled = true;
     ErrorFormatter.DisplayError(Settings.ErrorTargetID, args.ExceptionObject);
 }