Daily Archives: November 9, 2012

WinJS Tricks: Access is denied exception with multiple MessageDialogs

Using what you learned in the previous episodes of the WinJS Tricks Series about MessageDialogs and their custom buttons, you can write the following code, that displays two MessageDialogs in a sequence:

var dlg = new MessageDialog( 'First message' );

dlg.commands.append( new UICommand( 'OK', function() {
  new MessageDialog( 'Second message' ).showAsync().then( function() {
    // Do something useful here...
  } );
} ) );

dlg.showAsync();

The “only” problem with this code is that it unmerficully crashes your app without any notification. If you run your app in Debug mode you can get the following Access is denied exception:

MessageDialog-Access-denied

Do you see the bug? If not, you can learn why that happens and how to fix it from the next episode of the series:

(720p, full screen view recommended)

 

Technorati-címkék: ,,,,