Tuesday, March 11, 2008

My XBAP deployment fails on user account, while administrators can run it well - what to do?

I know only one person, who has following problem, however it makes sense to post all steps to perform in order to solve the problem. Let's start from the error:

While trying to run XBAP application with user's account on my machine, I get following error:

System.UnauthorizedAccessException was unhandled Message="Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))" Source="System.Deployment

while administrators on the same machine have no problem to run the same XBAPs.

Side note: Similar problems might be while running XPS viewer directly from Internet Explorer.

Declaimer: This posting is provided "AS IS" with no warranties, and confers no rights. Following methods are not an officially supported feature. You can use it strictly for debugging purposes.

Following steps you should take in order to find the root of the problem

  • Check it your users able to get cookies (they should be able to write into isolated storage)
    in order to do it, repair simple HTML page on web server in the same security zone and put following code there

    document.cookie = "testxbapcookie=whatever;expires=12/12/2999 00:00:00";
    var c =
    document.cookie.match ( '(^|;) ?testxbapcookie=([^;]*)(;|$)' );
    document.cookie = "testxbapcookie=whatever;expires=12/12/1999 00:00:00";
    alert("cannot set cookie");

    If you see alert - enable cookie support for this security zone
  • Next step is to check if the user able to write into storage. To do it try to copy and then read some file into "documents and settings\[USERNAME]\Local Settings\Apps\2.0" directory. If you cannot - ask the administrator to give full access to the user to this directory - it's the user's own directory
  • Next step is to check ability of the user to write into some registry key. Try to write something into HKCU\Software\Classes\Software\Microsoft\Windows\CurrentVersion\Deployment\SideBySide\2.0 if you cannot - ask administrator to give right for this node. Alternatively, you can run simple .NET program.

    Guid ri = new Guid("a5c62f6d-5e3e-4cd9-b345-6b281d7a1d1e");
    object o = GetUserStore(0,IntPtr.Zero, ref ri);

    if it failed, enable the access for this node. If you want to me  general, check whether client can read HKCU\Software\Classes before. Also you can check and access to HKCR\Interface\{79EAC9C9-BAF9-11CE-8C82-00AA004BA90B} registry node.
  • If the problem still exists, ask administrator to go to HKLM\SOFTWARE\Microsoft\.NETFramework\Windows Presentation Foundation\Hosting node in registry and create DWORD RunUnrestricted=1 value. This will force PresentationHost to restart itself might solve the problem. Please note, setting RunUnrestricted value might have side effects
  • If you still have a problem - try to delete and recreate the user or reinstall your operation system.

Have a nice day and don't fall with problem - if you do not really need XBAP - do not use it!

No comments: