[FIXED] Xamarin macOs CreateBookmarkData WithSecurityScope results in The file couldn’t be opened


This code used to work, but after installing Visual Studio for Mac 2022 it doesn’t work anymore:

                var dlg = NSOpenPanel.OpenPanel;
                dlg.AllowsMultipleSelection = false;
                dlg.CanChooseFiles = false;
                dlg.CanChooseDirectories = true;

                if (dlg.RunModal() == 1)
                    if (dlg.Url != null)
                        NSError error = new NSError();
                        string[] resourceValues = {  };
                        var data = dlg.Url.CreateBookmarkData(NSUrlBookmarkCreationOptions.WithSecurityScope, resourceValues, null, out error);
                        var userDefaults = NSUserDefaults.StandardUserDefaults;
                        userDefaults.SetValueForKey(data, new NSString("MBVFolderBookmark"));


The error parameter is {The file couldn’t be opened.}
The same error show with files or folders.

Other options of NSUrlBookmarkCreationOptions still works.

What can it be?


I seems that my certificate (developer ID) was expired.
Creating a new one did solve this problem…

Answered By – Marcel de Graaf

Answer Checked By – Candace Johnson (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published