2

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.

hvarlik
  • 43
  • 8
  • 1
    show at least stack trace otherwise it's almost impossible to tell what is causing the exception. – Pawel Jan 07 '15 at 22:18
  • @Pawel I wrote some exception details. Are they what you asked for? – hvarlik Jan 08 '15 at 06:45
  • It may be that you're sending two popups at the same time. You can only have one `MessageDialog` showing at a time. – Nate Diamond Jan 15 '15 at 18:20
  • @NateDiamond I don't understand why two message dialogs at different pages cause a problem. – hvarlik Jan 16 '15 at 17:51
  • You can only have one message dialog showing at a time. If you try and show two at the same time, it will throw this exception. Give it a go. Make two popups; show both of them. – Nate Diamond Jan 16 '15 at 17:53
  • @NateDiamond what I mean is, they are not shown at the same time. They are displayed at different pages, and at different times. – hvarlik Jan 18 '15 at 22:05
  • I would debug it and make sure that it's not accidentally being called twice. – Nate Diamond Jan 19 '15 at 02:14
  • This may solve your problem: https://stackoverflow.com/questions/14488587/how-to-allow-for-multiple-popups-at-once-in-winrt. – Jasper Feb 04 '20 at 12:51

0 Answers0