Q: NullReferenceException when calling ShowDialog on Android 2 I get a NullReferenceException when calling Acitiviy.ShowDialog(int) in response to a user tapping a button. The exception occurs in Android 2.1 but not in Android 4.2. Here is the Stacktrace:
UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
at (wrapper delegate-invoke) <Module>.invoke_void__this___intptr_intptr_intptr_JValue[] (intptr,intptr,intptr,Android.Runtime.JValue[]) <0x000b3>
at Android.Runtime.JNIEnv.CallVoidMethod (intptr,intptr,Android.Runtime.JValue[]) <0x00053>
at Android.App.Activity.ShowDialog (int) <0x0011f>
at MyApp.AndroidApp.InvoiceActivity.ShowScheduleDateDialog (object,System.EventArgs) <0x0003b>
at Android.Views.View/IOnClickListenerImplementor.OnClick (Android.Views.View) <0x00057>
at Android.Views.View/IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (intptr,intptr,intptr) <0x00063>
at (wrapper dynamic-method) object.be0dcca3-9ca4-47b4-a6a4-f691d34675f1 (intptr,intptr,intptr) <0x00043>

Any ideas?

A: I found a weird workaround. I noticed that if the app opens an AlertDialog at any point before trying to show the DatePickerDialog, it works. So doing this:
var helperDialog = new AlertDialog.Builder(this).SetTitle("").Show();
helperDialog.Hide();

right before returning the DatePickerDialog in OnCreateDialog seems to fix the problem. It's a very ugly workaround, but it doesn't seem to have any side effects for the final user.
No idea if this is an Android bug or Monodroid bug.
