Bug 21397 - DisplayAlert throws ArgumentNullException
Summary: DisplayAlert throws ArgumentNullException
Status: RESOLVED INVALID
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.2.1
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-07-17 12:51 UTC by John Miller [MSFT]
Modified: 2018-05-14 12:52 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description John Miller [MSFT] 2014-07-17 12:51:09 UTC
### Overview: 

    Passing "null" as the "cancel" parameter to DisplayAlert method causes an AgrumentNullException.

### Steps to Reproduce: 

    1. DisplayAlert ("Alert", "You have been alerted", "OK", null);

### Actual Results: 

    Unhandled Exception:
System.ArgumentNullException: Argument cannot be null.
Parameter name: cancel
  at Xamarin.Forms.Page.DisplayAlert (System.String title, System.String message, System.String accept, System.String cancel) [0x00000] in <filename unknown>:0 
  at TestDisplayAlert.TestPage+<TestPage>c__async0.MoveNext () [0x00022] in /Users/John/Projects/TestDisplayAlert/TestDisplayAlert/TestPage.cs:12 
2014-07-17 09:48:49.854 TestDisplayAlertiOS[30395:70b] Unhandled managed exception: Argument cannot be null.
Parameter name: cancel (System.ArgumentNullException)
  at Xamarin.Forms.Page.DisplayAlert (System.String title, System.String message, System.String accept, System.String cancel) [0x00000] in <filename unknown>:0 
  at TestDisplayAlert.TestPage+<TestPage>c__async0.MoveNext () [0x00022] in /Users/John/Projects/TestDisplayAlert/TestDisplayAlert/TestPage.cs:12 

### Expected Results: 

    Allow null to be passed so that a cancel button is not required.

### Build Date & Platform: 

    XF 1.2.1

### Additional Information: 

    This was working with expected results in previous versions.
Comment 1 Eric Maupin 2014-07-17 16:43:42 UTC
This never worked properly on all platforms. There is now a separate overload that takes a single string to allow for this.
Comment 2 Rob Houweling 2018-05-07 07:59:47 UTC
I have an issue that is related to this bug.

Some users of my app experience crashes on the DisplayAlert call without the cancel parameter. 6 out of 10 devices seem to have this issue.
This happens on Android versions from 5 to 8 and on different phones (LG G6, Huawei P8 Lite, Google Pixel, etc). What's strange is that I can't seem to reproduce it...

The Xamarin Forms version is 2.5.1.444934.

Crash reports that I receive all have the following:
android.runtime.JavaProxyThrowable: System.ArgumentNullException: Value cannot be null.
Parameter name: cancel
  at Xamarin.Forms.Page.DisplayAlert (System.String title, System.String message, System.String accept, System.String cancel) [0x00009] in <afec569c85894ae9a18371a2fecd2d37>:0 
  at Xamarin.Forms.Page.DisplayAlert (System.String title, System.String message, System.String cancel) [0x00000] in <afec569c85894ae9a18371a2fecd2d37>:0 

Do you want me to create a new bug or should this one be reopened again?
Comment 3 Rob Houweling 2018-05-12 11:43:32 UTC
Please inform me what to do, do I need to create a new issue or do you need to reopen this one? Almost 10 percent of my app users is affected by this so this really needs to be looked at...
Comment 4 John Miller [MSFT] 2018-05-14 12:52:06 UTC
Hi Rob,

Please file a new issue here: https://github.com/xamarin/xamarin.forms/issues

If possible, please attach a sample project that reproduces the issue too. https://gist.github.com/jassmith/92405c300e54a01dcc6d