Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

AskUserForAgreementAsync throws NullReferenceException #25

Closed
infidelkea opened this issue Mar 9, 2015 · 0 comments
Closed

AskUserForAgreementAsync throws NullReferenceException #25

infidelkea opened this issue Mar 9, 2015 · 0 comments

Comments

@infidelkea
Copy link

File: HockeySDK-Windows\HockeySDK_WP81\Universal\CrashHandler.cs
Version: 2.2.2
Platform: WP8.1 Universal

AskUserForAgreementAsync does not handle the case where the user dismisses the message dialog using the back button on windows phone which means that ShowAsync returns null and the return clause will throw an exception

 SendCrashReportsAsync in App.xaml.cs:658 caught exception: System.NullReferenceException: Object reference not set to an instance of an object. at HockeyApp.CrashHandler.<AskUserForAgreementAsync>d__c.MoveNext() --- End of stack trace from previous location where exception was thrown
protected virtual async Task<bool> AskUserForAgreementAsync()
        {
            var messageDialog = new MessageDialog(LocalizedStrings.LocalizedResources.SendCrashQuestion, LocalizedStrings.LocalizedResources.CrashData);

            // Add commands and set their command ids
            messageDialog.Commands.Add(new UICommand(LocalizedStrings.LocalizedResources.Send, null, true));
            messageDialog.Commands.Add(new UICommand(LocalizedStrings.LocalizedResources.Delete, null, false));

            // Set the command that will be invoked by default
            messageDialog.DefaultCommandIndex = 1;

            // Show the message dialog and get the event that was invoked via the async operator
            var commandChosen = await messageDialog.ShowAsync();

            return (Boolean)commandChosen.Id;
        }
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant