Silverlight onerror callback handling

The silverlight object tag accepts the 'onerror' parameter, which refers to the javascript fragment of your choice. The default implementation created by the Visual Studio template collects a descriptive message and throws it as an Error (which allows, for example, IE to display a small warning triangle).

It seems to me that every time this callback is launched, our silverlight instance is dead and you need to refresh the page. Is that a reasonable conclusion?

Another issue is how best to handle this callback. Displaying a small warning icon is somewhat focused on developers, and this does not allow us (developers) to find out what actually does not work in the production process when it is running on the client machine. What do people do with this? A few of our (more or less specific) ideas:

  • Send an error message to the server through some open endpoint

  • Hide the silverlight object, show a nicer and more descriptive message to the user and the Refresh link to launch the Silverlight page again (we launch the full-size Silverlight application, so if the silverlight isn object doesn’t work, the client can also reboot anyway)

  • Somehow reload the object tag automatically to prevent the client from taking any action to restart (possibly in combination with some client notification of a system restart)

Ideas, thoughts, best practices, anti-patterns? What are you guys doing (except the silverlight application never fails, but this is another discussion)?

+3
source share
2 answers

Silverlight. Silverlight.CreateObjectEx() Silverlight.js. , , . , , , . :

Silverlight.createObjectEx(
     {
         source: '/../VideoPlayer.xap',
         parentElement: document.getElementById('movieplayerDiv'),
         id: 'VideoPlayer',
         properties: {
             width: '100%',
             height: '100%',
             background: '#FFd9e3d7',
             inplaceInstallPrompt: false,
             isWindowless: 'false',
             version: '2.0'
         },
         events: {
             onError: onSLError,
             onLoad: onSLLoad
         },

         initParams: "...",
         context: null
     });



    function onSLLoad(sender, args) {

    }

    function onSLError(sender, args) {
        //                alert('error');
    }

:

  • javascript , . Silverlight . CreateObjectEx, ;)
  • Silverlight 2 . 1) ( Application_UnhandledException). , . - (, - ...), ​​. , , - ( CLOG), . 2) Javascript. , . JQuery ( Javascript). - :

        $.post(this.href, { func: "countVote" },
    

    () {...} , , , . MVC, .

+2

Source: https://habr.com/ru/post/1709965/


All Articles