1

I am trying to install package programatically. And i need to create the Package manager instance. It's throwing E_ACESSDENIED!

Windows.Management.Deployment.PackageManager packageManager = new Windows.Management.Deployment.PackageManager();

Exception:

System.UnauthorizedAccessException: 'Access is denied. (Exception from 
HRESULT: 0x80070005 (E_ACCESSDENIED))'

I am in the administrative account. What's wrong with this API?

sohel14_cse_ju
  • 2,481
  • 9
  • 34
  • 55
  • Added the capability to manage package in the manifest following below answer and it worked : https://stackoverflow.com/questions/38721521/findpackagesforcurrentpublisher-in-windows-10-for-pc – sohel14_cse_ju Aug 27 '17 at 14:26

1 Answers1

1

You will need to declare the 'packageQuery' and/or 'packageManagement' capability (depending on which PackageManager APIs you need to use) in your manifest in order to create a PackageManager instance from a UWP app.

If you are planning to submit this app to the Windows Store, your account/app will need to get approved for using this restricted capability, otherwise the Store submission will get rejected.

Stefan Wick MSFT
  • 13,600
  • 1
  • 32
  • 51