question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

KeyboardOverlap: System.ObjectDisposedException has been thrown.

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

5reactions
stivenbrcommented, Feb 14, 2019

“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).

0reactions
rmgalantecommented, Apr 12, 2019

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;
        }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - System.ObjectDisposedException
ObjectDisposedException is: The exception that is thrown when an operation is performed on a disposed object. (source).
Read more >
ObjectDisposedException Class (System)
The exception that is thrown when an operation is performed on a disposed object. ... or IAsyncDisposable interface, and that object has been...
Read more >
System.ObjectDisposedException Class
The following example throws a ObjectDisposedException instance created using this constructor. ... Caught: Oh-oh! This object has been disposed! Object name: " ...
Read more >
Xamarin.Forms — Xamarin Community Forums
We have been using Prism in our Xamarin.Forms project. ... System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Android.Views.
Read more >
System.ObjectDisposedException thrown by ...
ObjectDisposedException : The collection has been disposed. Object name: 'BlockingCollection'. at System.Collections.Concurrent.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found