Forum Xamarin.Forms

Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.PickerEditText'.

NielsCupNielsCup NLMember ✭✭✭
edited June 2019 in Xamarin.Forms

The DatePicker causes the following exception on Android after opening and closing the page and then tapping the DatePicker Cancel button. Tapping the OK button does not throw this error:

Datepicker Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.PickerEditText'.

Any ideas how to solve this?

ps. I use Xamarin.Forms 3.6.0.220655

Best Answers

  • NielsCupNielsCup NLMember ✭✭✭
    Accepted Answer

    Thanks for asking, I created a test project: turns out this issue occurs with Xamarin.Forms version 3.6.0.220655 (our current version), 3.6.0.264807.

    It works as expected using XF version 3.4.0.1008975, 3.6.0.293080, 3.6.0.344457

Answers

  • YelinzhYelinzh Member, Xamarin Team Xamurai
    edited June 2019

    I tried to reproduce your issue, but failed. Did the exception always occur or just exist once?
    The exception occurs when 'The object is terminated when no initialization is complete'. You can try adding an if conditional statement.

    if(xxx ! = null)
    {
        //
    }
    
  • NielsCupNielsCup NLMember ✭✭✭

    I can reproduce it each time. The funny thing is that it only happens when tapping the pickers "Cancel" button. The "Ok" button works fine. I have made a custom renderer so I can debug the events and see what happens: the Control is null and initialised when expected and CreateNativeControl is called when expected.

  • JohnHardmanJohnHardman GBUniversity admin

    @NielsCup said:
    The DatePicker causes the following exception on Android after opening and closing the page and then tapping the DatePicker Cancel button. Tapping the OK button does not throw this error:

    Post your code.

    You say that you open the page, then close the page, then tap on the DatePicker. Which page is the DatePicker on?

  • NielsCupNielsCup NLMember ✭✭✭
    Accepted Answer

    Thanks for asking, I created a test project: turns out this issue occurs with Xamarin.Forms version 3.6.0.220655 (our current version), 3.6.0.264807.

    It works as expected using XF version 3.4.0.1008975, 3.6.0.293080, 3.6.0.344457

Sign In or Register to comment.