Xamarin.Forms.Plugins icon indicating copy to clipboard operation
Xamarin.Forms.Plugins copied to clipboard

KeyboardOverlap: System.ObjectDisposedException has been thrown.

Open dzmitry-antonenka opened this issue 6 years ago • 7 comments

The exception message is: Cannot access a disposed object. Object name: 'KeyboardOverlapRenderer'

Call stack: UIKit.UIApplication.UIApplicationMain() in UIKit.UIApplication.Main(string[] args, System.IntPtr principal, System.IntPtr delegate) in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/UIKit/UIApplication.cs:79 UIKit.UIApplication.Main(string[] args, string principalClassName, string delegateClassName) in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/UIKit/UIApplication.cs:63 iOS.Application.Main(string[] args) in …/Main.cs:17

dzmitry-antonenka avatar Oct 24 '18 13:10 dzmitry-antonenka

I have the same problem either, especially happens in debug mode a lot

ikeremozcan avatar Nov 01 '18 12:11 ikeremozcan

I also have the same problem. Error Message: Unhandled Exception: System.ObjectDisposedException: Cannot access a disposed object. Object name: 'KeyboardOverlapRenderer'.

aparnatiwari30 avatar Dec 06 '18 07:12 aparnatiwari30

Has anyone had any luck with this? I am experiencing the same issue.

omanak avatar Dec 11 '18 10:12 omanak

Same problem here :(

cooliopas avatar Dec 12 '18 05:12 cooliopas

I have same problem: Cannot access a disposed object. Object name: 'KeyboardOverlapRenderer'.

icalderond avatar Jan 31 '19 21:01 icalderond

"Solution" ?

Hello, In my case it happens when I close the session with masterdetailpage, to solve it we have to close the menu with IsPresented and leave a waiting time to perform the navigation.

Example with PRISM MVVM and MessagingCenter.

MasterPageViewModel.cs (Method)

private async void Logout() 
{
     MessagingCenter.Send(this, "Logout");
     await Task.Delay(500);
              
     // Navigation Login
     await this.NavigationService.NavigateAsync(new Uri("/LoginPage", UriKind.Absolute));
}

MasterPage.xaml.cs

namespace ProjectXamarin.Views
{
    using ProjectXamarin.ViewModels;
    using Xamarin.Forms;

    public partial class MasterPage : MasterDetailPage
    {
        public MasterPage()
        {
            InitializeComponent();

            // Close Menu
            MessagingCenter.Unsubscribe<MasterPageViewModel>(this, "Logout");
            MessagingCenter.Subscribe<MasterPageViewModel>(this, "Logout", (sender) =>
            {
                this.CloseMenu();
            });
        }

        private void CloseMenu() 
        {
            this.IsPresented = false;
        }
    }
}

Sorry my English (Google translator).

stivenbr avatar Feb 14 '19 21:02 stivenbr

I confirmed that stivenbr's solution worked for me. I'm build an app using the Prism framework. So my changes went into one file, the view model class.

MasterDetailPageViewModel.cs

private async Task ItemTappedAsync(MasterDetailPageMenuItem menuItem)
{
        // If the user is logging out, navigate to the LoginPage and make it the main page.
        if (menuItem.Title == Constants.LogoutPage)
        {
                await NavigationService.GoBackToRootAsync();
                // Prevent unhandled exception, System.ObjectDisposedException, on object, KeyboardOverlapRenderer.
                MasterDetailPage1 page = (App.Current.MainPage as MasterDetailPage1);
                if (page != null)
                {
                        page.IsPresented = false;                        
                }
                // Relinquish control to the UI thread
                await Task.Delay(500);
                // Now navigate to the LoginPage
                await NavigationService.NavigateAsync(Constants.LoginPageUri);
                return;
        }
}

rmgalante avatar Apr 12 '19 12:04 rmgalante