Windows runtime 在运行时检查Windows应用商店应用程序AppxManifest

Windows runtime 在运行时检查Windows应用商店应用程序AppxManifest,windows-runtime,windows-phone-8.1,winrt-xaml,Windows Runtime,Windows Phone 8.1,Winrt Xaml,我尝试在运行时加载AppxManifest以读取应用程序的版本。我喜欢这篇文章: 我试了一下帖子上的那句话: var doc = XDocument.Load("AppxManifest.xml", LoadOptions.None); 但这会引发以下异常: {System.Xml.XmlException: An internal error has occurred. at System.Xml.XmlXapResolver.GetEntity(Uri absoluteUri, S

我尝试在运行时加载AppxManifest以读取应用程序的版本。我喜欢这篇文章:

我试了一下帖子上的那句话:

var doc = XDocument.Load("AppxManifest.xml", LoadOptions.None);
但这会引发以下异常:

{System.Xml.XmlException: An internal error has occurred.
   at System.Xml.XmlXapResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
   at System.Xml.XmlTextReaderImpl.FinishInitUriString()
   at System.Xml.XmlTextReaderImpl..ctor(String uriStr, XmlReaderSettings settings, XmlParserContext context, XmlResolver uriResolver)
   at System.Xml.XmlReaderSettings.CreateReader(String inputUri, XmlParserContext inputContext)
   at System.Xml.XmlReader.Create(String inputUri, XmlReaderSettings settings, XmlParserContext inputContext)
   at System.Xml.Linq.XDocument.Load(String uri, LoadOptions options)
   at MyMedi.Src.Utilities.GetVersion()
   at MyMedi.WindowsPhone.Test.Src.UtilitiesTest.Utilities_GetVersionTest()}
谁能告诉我我做错了什么

谢谢
NPadrutt

我不确定您为什么要这样做,但您可以尝试加载文件引用中的文档

不过,有一种更容易实现目标的方法

Package package = Package.Current;
PackageId packageId = package.Id;
PackageVersion version = packageId.Version;

var versionString = string.Format(
               CultureInfo.InvariantCulture,
               "{0}.{1}.{2}.{3}",
               version.Major,
               version.Minor,
               version.Build,
               version.Revision);

据我所知,确实如此,这将是加载它的正确方式。