System.ObjectDisposedException: Cannot access a disposed object. Object name: 'PrimaryToolbarItem'.

Application is crashing after adding the toolbar in master detail page, It is crashing if we come back from the current page and after tapping different page on master and on that page I have added toolbar icons.

{System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'PrimaryToolbarItem'.
at Foundation.NSObject.get_SuperHandle () [0x0004a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/Foundation/NSObject2.cs:456
at UIKit.UIBarButtonItem.set_Image (UIKit.UIImage value) [0x00033] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/UIBarButtonItem.g.cs:652
at Xamarin.Forms.Platform.iOS.ToolbarItemExtensions+PrimaryToolbarItem.UpdateIconAndStyle () [0x00031] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Extensions\ToolbarItemExtensions.cs:84
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state) [0x00000] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/Foundation/NSAction.cs:178
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at MotorApp.iOS.Application.Main (System.String[] args) [0x00002] in /Volumes/PMTSL/Ashish/ABC/MotorCatalogApp/ABCApp/MotorApp.iOS/Main.cs:14 }

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    It seems you want to consume a toolbar item which has been released. How did you add this item on another detail page? Would you mind sharing some code or sample here?

  • ASHISHRANJAN.1450ASHISHRANJAN.1450 USMember ✭✭
    edited December 2019

    I have added the toolbar using the xaml page and I am setting the icon after tapping on that. If I add this toolbar on first detail page then it working fine but it is crashing if we navigate to other detail page which contains the toolbar items.

    <ContentPage.ToolbarItems>


    </ContentPage.ToolbarItems>

  • Solved the issue, The problem is with the FFImageloading and after removing the FFImageloading refreance from the AppDelegate method it works.

    Thanks for help

Sign In or Register to comment.