locked
javascript doesn't get access to Windows.Storage.KnownFolders.picturesLibrary ??? RRS feed

  • Question

  • Running through some coding examples in a book - when attempting to access Windows.Storage.KnownFolders.picturesLibrary, consistently getting javascript error 0x80070005 - JavaScript runtime error: Access is denied.

    example -  this line throws the error:

    var lib = Windows.Storage.KnownFolders.documentsLibrary;

    And this happens with Pictures Library capability enabled in the appmanifest... STRANGE

    (And yes, I have tried this with several different javascript code examples...)

     ** I guess I should add that I'm using VS2012 Express (SP1)  on Win8 Pro

     

     


    Thursday, December 6, 2012 11:32 PM

Answers

  • Very curious. I tried the app on a Win8 enterprise machine, a Win8 Pro, and a plain Win8 client, and it worked in all circumstances, though in the latter two cases I was running outside VS, but if there was an exception the app would have terminated.

    So I'm not sure what isn't working for you. I tried it as-is (accessing the documents library as well as pictureLibrary), no problem in any case. Unfortunately, I don't have any other advice I can offer.

    .Kraig

    By the way, if you look at the documentation on the documents library capability, http://msdn.microsoft.com/en-us/library/windows/apps/hh464936.aspx#special_use_capabilities, you'll see that it's listed as "special use" and has a number of limitations. It has some very limited use cases that are allowed, and won't pass Store cert in the way you're using it.

    • Marked as answer by Song Tian Tuesday, December 18, 2012 8:52 AM
    Wednesday, December 12, 2012 11:35 PM

All replies

  • Your line of code is trying to access the documentsLibrary and not the picturesLibrary, hence the exception. If you have the Pictures Library capability checked, then this line should work:

    var lib = Windows.Storage.KnownFolders.picturesLibrary;

    If for some reason you keep getting exceptions, try uninstalling the app from the Start screen (right click and select uninstall from the app bar), to be sure that the app is freshly deployed the next time you run in VS.

    .Kraig

    Friday, December 7, 2012 3:02 AM
  • wow, bizarre cut paste typo there, documentsLibrary  line was from another sample i was testing!

    actual "access Denied" problem child in this case  really is

    var lib = Windows.Storage.KnownFolders.picturesLibrary;



    Will try the uninstall, shortly...
    Friday, December 7, 2012 6:49 PM
  • Also just try creating a fresh blank app project, check the box in the manifest capabilities, and add the one line of code. At least that would separate out any issues with the specific project that's having trouble.
    Friday, December 7, 2012 7:10 PM
  • tried that too...

    fresh blank Javascript project, set the pictures Library capability, added the one line of code:

    var lib = Windows.Storage.KnownFolders.picturesLibrary;

    same error...  javascript error 0x80070005 - JavaScript runtime error: Access is denied.

    I have built and  run C# examples that access the same folder, no problem with them!

    Saturday, December 8, 2012 12:06 AM
  • Very strange. And this is with the RTM/release versions of Visual Studio Express, on the released Win8? If there might be a chance you're using older tools and such, that might pose a problem.

    I can take a look at the project (that is, try it on my machine) if you can zip up its contents and drop it somewhere for me.

    • Marked as answer by Song Tian Wednesday, December 12, 2012 5:03 AM
    • Unmarked as answer by rockandroller Wednesday, December 12, 2012 9:35 PM
    Saturday, December 8, 2012 12:17 AM
  • Yes, fresh release Win8 install, with freshly downloaded release VS2012 Express for Win8.

    And VS SP1 has been applied

    zip file is the project folder...  see http://rockandroller.net/App6.zip

    Wednesday, December 12, 2012 9:32 PM
  • Very curious. I tried the app on a Win8 enterprise machine, a Win8 Pro, and a plain Win8 client, and it worked in all circumstances, though in the latter two cases I was running outside VS, but if there was an exception the app would have terminated.

    So I'm not sure what isn't working for you. I tried it as-is (accessing the documents library as well as pictureLibrary), no problem in any case. Unfortunately, I don't have any other advice I can offer.

    .Kraig

    By the way, if you look at the documentation on the documents library capability, http://msdn.microsoft.com/en-us/library/windows/apps/hh464936.aspx#special_use_capabilities, you'll see that it's listed as "special use" and has a number of limitations. It has some very limited use cases that are allowed, and won't pass Store cert in the way you're using it.

    • Marked as answer by Song Tian Tuesday, December 18, 2012 8:52 AM
    Wednesday, December 12, 2012 11:35 PM
  • Hey Rocky,

    Try your app on another machine there and see if this is simply a case of that one machine being messed up.

    -Jeff


    Jeff Sanders (MSFT)

    Thursday, December 13, 2012 3:06 PM
    Moderator