Why CurrentApp::AppId take so long in Windows Phone 10?

雨燕双飞 提交于 2019-12-11 09:43:28

问题


I have a windows 8 universal project and have a function to get APP ID, The following function works well in Windows Phone 8.1

Platform::Guid  appId = Windows::ApplicationModel::Store::CurrentApp::AppId;

however, it spent around 40s in Windows Phone 10.

From MSDN, only the Metadata is different,

May I know is it caused by the metadata? And how to solve it?


回答1:


To instead of using AppID, you might use the following code,

Windows::ApplicationModel::Package^ package = Windows::ApplicationModel::Package::Current;
Windows::ApplicationModel::PackageId^ packageId = package->Id;
Windows::ApplicationModel::PackageVersion version = packageId->Version;

Platform::String^ output = 
  "Name: \"" + packageId->Name + "\"\n" +
  "Version: " + version.Major.ToString() + "." 
              + version.Minor.ToString() + "." 
              + version.Revision.ToString() + "." 
              + version.Build.ToString() + "\n" +
  "Architecture: " + packageId->Architecture.ToString() + "\n" +
  "ResourceId: \"" + packageId->ResourceId + "\"\n" +
  "Publisher: \"" + packageId->Publisher + "\"\n" +
  "PublisherId: \"" + packageId->PublisherId + "\"\n" +
  "FullName: \"" + packageId->FullName + "\"\n" +
  "FamilyName: \"" + packageId->FamilyName + "\"\n" +
  "IsFramework: " + package->IsFramework.ToString();

Sample output from device

Output: Name: "f3e02737-ddfa-47a0-a837-37ee53459898" Version: 1.0.0.0 Architecture: Arm ResourceId: "" Publisher: "CN=heefan" PublisherId: "gsbawe9kfjm1p" FullName: "f3e02737-ddfa-47a0-a837-37ee53459898_1.0.0.0_arm__gsbawe9kfjm1p" FamilyName: "f3e02737-ddfa-47a0-a837-37ee53459898_gsbawe9kfjm1p" IsFramework: false

I also have no idea why AppID take long time to compute.



来源:https://stackoverflow.com/questions/34748044/why-currentappappid-take-so-long-in-windows-phone-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!