2013-05-09 38 views
0

當用戶點擊一個按鈕時,調用Acitiviy.ShowDialog(int)時出現NullReferenceException異常。 Android 2.1中發生異常,而Android 4.2中則不會。這裏是Stacktrace:在Android 2上調用ShowDialog時發生NullReferenceException異常

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> 

任何想法?

+0

你應該發佈代碼本身,從這我們將無法幫助你。 – Gilson 2013-05-09 17:47:52

回答

0

我發現了一個奇怪的解決方法。我注意到,如果應用程序在嘗試顯示DatePickerDialog之前在任何時候打開AlertDialog,它都會起作用。所以這樣做:

var helperDialog = new AlertDialog.Builder(this).SetTitle("").Show(); 
helperDialog.Hide(); 

就在返回OnCreateDialog中的DatePickerDialog之前似乎解決了這個問題。這是一個非常醜陋的解決方法,但它似乎沒有任何最終用戶的副作用。

不知道這是一個Android錯誤還是Monodroid錯誤。

相關問題