UnAuthorizedAccessException while accessing the GetPath() method for MediaLibrary

0

I am really stuck in a weird issue which I couldn't reproduce at my end but it is occurring frequently at user's end. According to stack trace it looks like when the user is navigated to specific page, the app crashes. Following the stack trace of that problem which is received from Microsoft.

Frame    Image                                                    Function                                                                                                               Offset        
0        Microsoft.Xna.Framework.MediaLibraryExtensions.ni.dll    Microsoft.Xna.Framework.Media.PhoneExtensions.MediaLibraryExtensions.ThrowExceptionFromResult                          0x00000f5e    
1        Microsoft.Xna.Framework.MediaLibraryExtensions.ni.dll    Microsoft.Xna.Framework.Media.PhoneExtensions.MediaLibraryExtensions.GetPathFromItemInternal                           0x00000050    
2        Microsoft.Xna.Framework.MediaLibraryExtensions.ni.dll    Microsoft.Xna.Framework.Media.PhoneExtensions.MediaLibraryExtensions.GetPath                                           0x00000022    
3        InstaRepost.ni.DLL                                       InstaRepost.Gallery.OnNavigatedTo                                                                                      0x000000ae    
4        Microsoft.Phone.ni.dll                                   Microsoft.Phone.Controls.PhoneApplicationPage.InternalOnNavigatedTo                                                    0x000002d4    
5        Microsoft.Phone.ni.dll                                   Microsoft.Phone.Controls.PhoneApplicationPage.Microsoft.Phone.Controls.IPhoneApplicationPage.InternalOnNavigatedToX    0x0000000c    
6        Microsoft.Phone.ni.dll                                   System.Windows.Navigation.NavigationService.RaiseNavigated                                                             0x0000038e    
7        Microsoft.Phone.ni.dll                                   System.Windows.Navigation.NavigationService.CompleteNavigation                                                         0x00000158    
8        Microsoft.Phone.ni.dll                                   System.Windows.Navigation.NavigationService.ContentLoader_BeginLoad_Callback                                           0x000002aa    
9        Microsoft.Phone.ni.dll                                   System.Windows.Navigation.PageResourceContentLoader.BeginLoad_OnUIThread                                               0x000002b4    
10       Microsoft.Phone.ni.dll                                   System.Windows.Navigation.PageResourceContentLoader+__c__DisplayClass4._BeginLoad_b__0                                 0x0000000a

What I am trying to do in code is that I have images in Medialibrary as well as in IsolatedStorage of the app. So in order to display them I am reading their names from isolatedstorage and then opening it from the MediaLibrary.

for (int i = 0; i < filesNames.Length; i++)
       {
         if (!filesNames[i].Contains(".tmp") && !filesNames[i].Contains("_ApplicationSettings"))
            {
               obj = new VideoInformation();
               obj.videoName = filesNames[i];
               obj.timeCreated = isolatedStorageFile.GetCreationTime(filesNames[i]);
               for (int j = 0; j < instaRepostPictures.Count; j++)
                {
                   string imagePath = Pictures[j].GetPath();
                   if (imagePath.Contains(obj.videoName))
                    {
                     obj.thumbnailpath = PictureDecoder.DecodeJpeg(Pictures[j].GetThumbnail());
                            //obj.thumbnailpath.
                        }
                    }
                    pictureList.Add(obj);
                }
            }

I think the issue is in the GetPath function. I have checked the capabilities and ID_CAP_MEDIALIB_PHOTO capability. Kindly if anyone could help me identify this issue. I SHall be grateful.

c#
.net
windows-phone-8
unauthorizedaccessexcepti
media-library
asked on Stack Overflow Dec 10, 2014 by user1971051

1 Answer

0

Try adding this piece of code, as you must call the FrameworkDispatcher.Update method yourself to dispatch messages that are in the XNA Framework message queue.

Microsoft.Xna.Framework.FrameworkDispatcher.Update();

as you said make sure that your Capabilities are ticked from the Manifest.

Reference: MSDN

answered on Stack Overflow Dec 11, 2014 by Kulasangar

User contributions licensed under CC BY-SA 3.0