WordPress database error: [INSERT, UPDATE command denied to user '51213-2'@'10.10.21.1' for table 'wp_options']
INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES ('_transient_doing_cron', '1714877676.6500830650329589843750', 'yes') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)


Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372
{"id":1381,"date":"2013-04-08T11:27:01","date_gmt":"2013-04-08T09:27:01","guid":{"rendered":"http:\/\/www.jonathanantoine.com\/?p=1381"},"modified":"2013-04-08T11:27:01","modified_gmt":"2013-04-08T09:27:01","slug":"wpdev-custommessagebox-onnavigatedto-navigate-exception","status":"publish","type":"post","link":"http:\/\/www.jonathanantoine.com\/2013\/04\/08\/wpdev-custommessagebox-onnavigatedto-navigate-exception\/","title":{"rendered":"[WPDev] CustomMessageBox + OnNavigatedTo + Navigate = Exception !"},"content":{"rendered":"

\"CustomMessageBox\"The Windows Phone Toolkit<\/a> is really useful. <\/p>\n

Yesterday, while I was updating my ConsoTracker <\/a>app, I met a strange bug using the CustomMessageBox : it was raising a nullReference exception.<\/p>\n

Let’s see what was the issue and how to “fix” it.
\n<\/p>\n

What I was trying to do was this simple scenario :<\/p>\n

    \n
  1. Ask the use if he wants to review my app in the OnNavigatedTo event using a CustomMessageBox <\/li>\n
  2. If he answers ‘no’, navigate to another page.<\/li>\n
  3. If it answers ‘yes’, show the marketplace review task.<\/li>\n<\/ol>\n

    As I like playing with tasks, I was using this code :
    \n[csharp]
    \n protected async override void OnNavigatedTo(NavigationEventArgs e)
    \n {
    \n base.OnNavigatedTo(e);
    \n var mBox = new CustomMessageBox
    \n {
    \n Title = "Do you want to… ",
    \n Message = " … click on yes ?",
    \n LeftButtonContent = "Yes",
    \n RightButtonContent = "No"
    \n };
    \n var result = await ShowAsync(mBox);
    \n NavigationService.Navigate(new Uri("\/OtherPage.xaml", UriKind.RelativeOrAbsolute));
    \n }<\/p>\n

    public static async Task<CustomMessageBoxResult> ShowAsync(CustomMessageBox box)
    \n {
    \n var taskCompletionSource = new TaskCompletionSource<CustomMessageBoxResult>();
    \n box.Dismissed += (a, b) => taskCompletionSource.TrySetResult(b.Result);<\/p>\n

    try { box.Show(); }
    \n catch (Exception exception) { taskCompletionSource.TrySetException(exception); }<\/p>\n

    return await taskCompletionSource.Task;
    \n }
    \n[\/csharp]<\/p>\n

    This code was throwing an exception. To fix it, I downloaded the source of the Windows Phone Toolkit and I saw that at the end of the dismissal animation, it was trying to access the “Popup” object which was null : BOUM !<\/p>\n

    So… how did I fix it ? Simply by waiting for the popup to be unloaded instead of using directly the Dismissed event of the CustomMessageBox :
    \n[csharp]
    \npublic static async Task<CustomMessageBoxResult> ShowAsync(CustomMessageBox box)
    \n{
    \n var taskCompletionSource = new TaskCompletionSource<CustomMessageBoxResult>();
    \n var result = CustomMessageBoxResult.None;<\/p>\n

    \/\/Only store the result here.
    \n box.Dismissed += (a, b) => result = b.Result;<\/p>\n

    \/\/Use this event to set the result.
    \n box.Unloaded += (_, __) => taskCompletionSource.TrySetResult(result);<\/p>\n

    try { box.Show(); }
    \n catch (Exception exception) { taskCompletionSource.TrySetException(exception); }<\/p>\n

    return await taskCompletionSource.Task;
    \n}
    \n[\/csharp]<\/p>\n

    I hope it will save you some time too \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"

    The Windows Phone Toolkit is really useful. Yesterday, while I was updating my ConsoTracker app, I met a strange bug using the CustomMessageBox : it was raising a nullReference exception. Let’s see what was the…<\/p>\n","protected":false},"author":3,"featured_media":1385,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,4],"tags":[14,15,44,45],"_links":{"self":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/1381"}],"collection":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/comments?post=1381"}],"version-history":[{"count":8,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/1381\/revisions"}],"predecessor-version":[{"id":1390,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/1381\/revisions\/1390"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/media\/1385"}],"wp:attachment":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/media?parent=1381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/categories?post=1381"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/tags?post=1381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}