ShareLinkTask – How to identify published app Url?

Launchers & Choosers is now a pretty known concept in Windows Phone and they extend the capabilities of your app by reducing the complexity to just a few lines of code. However most newbies ignore the fact that proper use of some of launchers can is not only beneficial for apps users but also for app promotion. I’m specifically talking about ShareLinkTask here.

ShareLinkTask as the name suggests allows you to share a link (Url) with external world and since in Windows Phone the social media are integrated within the phone with a single click user can share the link on multiple channels like Hotmail, Facebook, Twitter, etc. Since ShareLinkTask is an extension to ShareStatusTask, you can provide link to your own app such that each time user shares content from your app, your app gets promoted. (Since the purpose of post is technical we’ll keep the discussion of whether that’s a good practice or not aside)

 ShareLinkTask share = new ShareLinkTask();
share.Title = "Microsoft Pakistan Community Blog";
share.Message = "How to identify published app Url?";
share.LinkUri = new Uri("", UriKind.Absolute);

 However a question that comes into mind is how can we identify the link to our app before its published? It yields that deep links to Windows Phone mrketplace follow a pattern as follows,<ProductId>

It appears that all we need to do is to read the value of ProductId from WMAppManifest.xml file found under project/properties and substitute in Url above.


However that’s not the case. Thanks to our intern Rida Qasim at Microsoft Innovatino Center, Lahore for highlighting that,

“During the app submission process, a new product ID is inserted into the manifest file".



The workaround is to read the ProductId attribute from WMAppManifest.xml file through code so that when the app is certified for marketplace your app has access to the new Product Id and makes use of it on runtime. Here’s the helper class to fetch that, 

public class DeepLinkHelper
private const string AppManifestName = "WMAppManifest.xml";
private const string AppNodeName = "App";
private const string AppProductIDAttributeName = "ProductID";

public static string BuildApplicationDeepLink()
var applicationId = Guid.Parse(GetManifestAttributeValue(AppProductIDAttributeName));

return BuildApplicationDeepLink(applicationId.ToString());

public static string BuildApplicationDeepLink(string applicationId)
return @"" + applicationId;

public static string GetManifestAttributeValue(string attributeName)
var xmlReaderSettings = new XmlReaderSettings
XmlResolver = new XmlXapResolver()

using (var xmlReader = XmlReader.Create(AppManifestName, xmlReaderSettings))

if (!xmlReader.IsStartElement())
throw new FormatException(AppManifestName + " is missing " + AppNodeName);

return xmlReader.GetAttribute(attributeName);

You can find the sample code at the end of following blog post, 

Comments (1)
  1. abdulrehman Altaf says:


Comments are closed.

Skip to main content