locked
WinRTError: Access is denied for Navbar

    Question

  • I wrote a WinJS Windows Store app that we are running on Windows 8.1 tablets.  We are capturing and logging exceptions, and when my co-worker took it up to show the boss (He's a lot like the pointy haired manager in Dilbert) the app started logging message we had never seen.

    The stack was simply:  WinRTError: Access is denied  and the message was Access is denied

    My co-worker said that the only trouble they had was that, early when trying it out, the navbar would become unresponsive. - and that happened several times.  I have a sort of split screen app, in that there is a div at the top that is always displayed (like a header) and then the navbar events I render various html pages in a div that takes up the rest of the screen.  I have been working on this thing and have never seen this error.  My co-worker and the boss were using their own tablet.

    Any ideas on how/why this is happening?  Thanks



    Phil

    Thursday, March 6, 2014 11:10 PM

Answers

  • Turns out there were several issues.  The error that the NavBar was throwing was 

    Unable to get property 'winControl' of undefined or null reference at NavBarContainer_updatePageUI

    • in ui.js line 47978:  var firstItem = this._surfaceEl.children[firstIndexOnCurrentPage].winControl._buttonEl;

    For some reason the NavBar was not hiding once the user made a selection, so the user could tap the thing several times, one right after the other, and this generated the error.  So the solution was to hide the navbar immediately after rendering the new page.  Like myNavBarDiv.winControl,hide()

    I also made some other changes, but they may have not been needed

    - to go to the new page, I handle the "navigated" event as shown below and used the rest of the code found in the sample here  

    WinJS.Navigation.addEventListener("navigated", function(ev) {
    var host = document.getElementById("divFindingsSteps");
    // MS: Call unload method on current scenario, if there is one
    host.winControl && host.winControl.unload && host.winControl.unload();
    WinJS.Utilities.empty(host);
    ev.detail.setPromise(WinJS.UI.Pages.render(target, host, ev.detail.state).then(function
    () {
        WinJS.Application.sessionState.lastUrl = target;
    }));
     })
    A helpful thing to understand for me was that if you do nothing, the framework fires the navigate event, which fires the navigated event. In the sample the navigate handler is in base.js, line 10037.   HTH.


    Phil

    • Marked as answer by pdschuller_ Wednesday, March 26, 2014 4:15 PM
    Wednesday, March 26, 2014 4:14 PM

All replies

  • Hi,

    There is not enough information to detect why the problem occur. I think that problem may occur because of the different screen size between your computer and your boss's. Different screen size can influence UI layout. You should design your apps that look good at any width, and you automatically get support for different screen sizes and orientations. And Plan your app for resizing from full screen down to the minimum width so that the UI reflows gracefully for various screen sizes, window sizes, and orientations. You can refer to the links below to get more information:

    http://msdn.microsoft.com/en-us/library/windows/apps/hh465349.aspx

    http://msdn.microsoft.com/en-us/library/windows/apps/dn297195.aspx

    http://msdn.microsoft.com/en-us/library/windows/apps/dn617214.aspx

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Friday, March 7, 2014 2:59 AM
  • Turns out there were several issues.  The error that the NavBar was throwing was 

    Unable to get property 'winControl' of undefined or null reference at NavBarContainer_updatePageUI

    • in ui.js line 47978:  var firstItem = this._surfaceEl.children[firstIndexOnCurrentPage].winControl._buttonEl;

    For some reason the NavBar was not hiding once the user made a selection, so the user could tap the thing several times, one right after the other, and this generated the error.  So the solution was to hide the navbar immediately after rendering the new page.  Like myNavBarDiv.winControl,hide()

    I also made some other changes, but they may have not been needed

    - to go to the new page, I handle the "navigated" event as shown below and used the rest of the code found in the sample here  

    WinJS.Navigation.addEventListener("navigated", function(ev) {
    var host = document.getElementById("divFindingsSteps");
    // MS: Call unload method on current scenario, if there is one
    host.winControl && host.winControl.unload && host.winControl.unload();
    WinJS.Utilities.empty(host);
    ev.detail.setPromise(WinJS.UI.Pages.render(target, host, ev.detail.state).then(function
    () {
        WinJS.Application.sessionState.lastUrl = target;
    }));
     })
    A helpful thing to understand for me was that if you do nothing, the framework fires the navigate event, which fires the navigated event. In the sample the navigate handler is in base.js, line 10037.   HTH.


    Phil

    • Marked as answer by pdschuller_ Wednesday, March 26, 2014 4:15 PM
    Wednesday, March 26, 2014 4:14 PM