I am working on a windows 8.1 app with which users can play tic tac toe. To make my app real-time, I take advantage of SignalR. Here is the code I wrote to send a game request to a user.
hubProxy.On<string>("ShowRequest", async (requestOwner) =>
{
await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
{
var messageDialog = new MessageDialog(requestOwner + " wants to play with you", "New Game Request");
messageDialog.Commands.Add(new UICommand("Accept", new UICommandInvokedHandler(CommandHandler)));
messageDialog.Commands.Add(new UICommand("Deny", new UICommandInvokedHandler(CommandHandler)));
messageDialog.DefaultCommandIndex = 1;
messageDialog.CancelCommandIndex = 2;
await messageDialog.ShowAsync();
});
});
When a user sends a request to another user, a message dialog appears on the user's screen to whom the request has been sent. If that user hits the accept button, another page of the application is displayed. On this page, users play the game and the winner is shown again with a message dialog (maybe that causes the error, I don't know). So far so good. However, if they go back to the previous page and send another request, the message dialog doesn't show up and an UnauthorizedAccessException is throwned at the line below.
await messageDialog.ShowAsync();
Here is the exception details:
Message: "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
Source: "Windows.UI"
StackTrace: " at Windows.UI.Popups.MessageDialog.ShowAsync()\r\n at XOX.AvailableUsersPage.<>c__DisplayClass7.<<.ctor>b__2>d__b.MoveNext()"
I looked at the similar questions both on stackoverflow and other sites, but they didn't help me.
Thank you
Edit: I really can't diagnose the reason of the exception. I put those code lines in a try-catch block, and no ecxeption throws! When I remove the messagedialog(the one announcing the winner) from the page users play the game on, again there is no exception.