0

I'm trying to get reference to a package for the current user by using[PackageManager.FindPackagesForUser(string usersid, string packagename, string publisher)

The MSDN documentation specifically says

userSecurityId

Type: System.String [.NET] | Platform::String [C++]

The user security identifier (SID). If this parameter is null, the packages are retrieved for the current user.

So, I call it like so FindPackageForUser(null, name, publisher) where neither name nor publisher is null(I checked while debugging). Yet, it throws an ArgumentNullException

Is this a bug in this class or am I doing something wrong?

Earlz
  • 62,085
  • 98
  • 303
  • 499
  • What are your values for `name` and `publisher` when you call? Does the exception specifically name the `usersid` as the problem? – Dan Puzey Oct 24 '12 at 15:58
  • It doesn't name any arguments and it appears to throw this exception in a native-code wrapper. name is the name of a package and publisher is the publisher of a package. I'm 99% sure they should be valid.. Even if they weren't, shouldn't this return an empty list and not throw an exception? @DanPuzey – Earlz Oct 24 '12 at 15:59

1 Answers1

1

The documentation is wrong. There are no "null strings" in the Windows Runtime. Pass an empty string to enumerate the packages for the current user.

Community
  • 1
  • 1
James McNellis
  • 348,265
  • 75
  • 913
  • 977
  • @JamesMcNellis They may have corrected it by now as shown [here](https://learn.microsoft.com/en-us/uwp/api/windows.management.deployment.packagemanager.findpackagesforuser#Windows_Management_Deployment_PackageManager_FindPackagesForUser_System_String_System_String_System_String_). – nam Mar 20 '19 at 16:45
  • @JamesMcNellis Would you have any suggestion or your thoughts on [this](https://stackoverflow.com/q/55270248/1232087) similar post? – nam Mar 21 '19 at 15:39