【问题标题】:PackageManager.FindPackagesForUser throwing ArgumentNullException for argument that is allowed to be null?PackageManager.FindPackagesForUser 为允许为空的参数抛出 ArgumentNullException?
【发布时间】:2012-10-25 00:36:25
【问题描述】:

我正在尝试使用 [PackageManager.FindPackagesForUser(string usersid, string packagename, string publisher)

为当前用户获取对包的引用

MSDN documentation 专门说

用户安全ID

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.

所以,我这样称呼它FindPackageForUser(null, name, publisher),其中名称和发布者都不是空的(我在调试时检查过)。然而,它会抛出一个ArgumentNullException

这是这个类的错误还是我做错了什么?

【问题讨论】:

  • 当您致电时,name 和 publisher 的值是多少?异常是否明确将usersid 命名为问题?
  • 它没有命名任何参数,并且似乎在本机代码包装器中引发了此异常。 name 是包的名称,publisher 是包的发布者。我 99% 确定它们应该是有效的。即使它们不是,这不应该返回一个空列表并且不抛出异常吗? @DanPuzey

标签: .net windows-8 windows-runtime windows-store argumentnullexception


【解决方案1】:

文档有误。 There are no "null strings" in the Windows Runtime.传递一个空字符串来枚举当前用户的包。

【讨论】:

  • @JamesMcNellis 他们现在可能已经纠正了它,如图所示here。
  • @JamesMcNellis 你对this类似的帖子有什么建议或想法吗?
猜你喜欢
  • 1970-01-01
  • 2019-11-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-29
相关资源
最近更新 更多