简体   繁体   English

Windows手机:如何获取当前的应用程序ID

[英]Windows phone: how get current application id

Is there any way to get ID of my application in app store without hardcode? 有没有办法在没有硬编码的情况下在应用程序商店中获取我的应用程序的ID? I need to use this value it self, so this way http://forums.create.msdn.com/forums/p/88847/533072.aspx will not help. 我需要自己使用这个值,所以这种方式http://forums.create.msdn.com/forums/p/88847/533072.aspx无济于事。

try this : var appId = Windows.ApplicationModel.Store.CurrentApp.AppId; 试试这个: var appId = Windows.ApplicationModel.Store.CurrentApp.AppId; it's documentation here 它的文档在这里

A couple of people answered your question in the post that you linked. 有几个人在您关联的帖子中回答了您的问题。

One answer is to get the ProductID value from your WMAppManifest.xml file. 一个答案是从WMAppManifest.xml文件中获取ProductID值。 This value WILL BE your marketplace application ID once the app is submitted. 提交应用程序后,此值将成为您的市场应用程序ID。 When your app is submitted the value in your WMAppManifest.xml file is changed to be the value for the marketplace. 提交您的应用程序时,WMAppManifest.xml文件中的值将更改为市场的值。 While using this value will not work when testing your app, it WILL work once it has been approved. 虽然在测试应用程序时使用此值不起作用,但一旦获得批准,它将起作用。

The second way to to start the submission process and go to the details page to get the URI for your app. 第二种方法是启动提交过程并转到详细信息页面以获取应用程序的URI。

Use this in your code: 在您的代码中使用它:

string appID = (from manifest in 
  System.Xml.Linq.XElement.Load("WMAppManifest.xml").Descendants("App") 
select 
manifest).SingleOrDefault().Attribute("ProductID").Value;

Keep in mind, you need to add System.Xml.Linq reference and also include the Namespace. 请记住,您需要添加System.Xml.Linq引用并包含命名空间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM