您好朋友,我正在关注此链接以实现从应用程序内部检查更新。但我没有实现它,我已经扩展了请求,我认为它的内容存在问题。
问题是它无法获得更新版本。
var request = WebRequest.Create(url); // here i checked it on applying breakpoints
private Task<Version> GetUpdatedVersion()
{
var cultureInfoName = CultureInfo.CurrentUICulture.Name;
var url = string.Format("http://marketplaceedgeservice.windowsphone.com/v8/catalog/apps/{0}?os={1}&cc={2}&oc=&lang={3}",
GetManifestAttributeValue("ProductID"),
Environment.OSVersion.Version,
cultureInfoName.Substring(cultureInfoName.Length - 2).ToUpperInvariant(),
cultureInfoName);
var request = WebRequest.Create(url);
return Task.Factory.FromAsync(request.BeginGetResponse, result =>
{
var response = (HttpWebResponse)request.EndGetResponse(result);
if (response.StatusCode != HttpStatusCode.OK)
{
throw new WebException("Http Error: " + response.StatusCode);
}
using (var outputStream = response.GetResponseStream())
{
using (var reader = XmlReader.Create(outputStream))
{
reader.MoveToContent();
var aNamespace = reader.LookupNamespace("a");
reader.ReadToFollowing("entry", aNamespace);
reader.ReadToDescendant("version");
return new Version(reader.ReadElementContentAsString());
}
}
}, null);
}