仅在发布模式下的 UWP 异常
UWP exception in release mode only
我正在尝试将 XmlReader 加载到 System.ServiceModel.Syndication.SyndicationFeed,它仅在发布模式下导致异常,但在调试模式下工作
加载代码
using (var xmlReader = XmlReader.Create(new StringReader(stringXML), new XmlReaderSettings { Async = true, IgnoreWhitespace = true, IgnoreComments = true }))
{
System.ServiceModel.Syndication.SyndicationFeed feed = System.ServiceModel.Syndication.SyndicationFeed.Load(xmlReader);
}
异常
System.Reflection.MissingRuntimeArtifactException: ‘Cannot retrieve a MethodInfo for this delegate because the method it targeted (System.ServiceModel.Syndication.SyndicationFeedFormatter.DefaultUriParser(XmlUriData, Uri&)) was not enabled for metadata using the Dynamic attribute. For more information, please visit https://go.microsoft.com/fwlink/?LinkID=616868’
将此代码添加到 Default.rd.xml 文件可解决问题
<Library Name="SyndicationFeed">
<Assembly Name="System.ServiceModel.Syndication" Activate="Required All" Browse="Required All" Serialize="Required All" Dynamic="Required All" />
<Namespace Name="System.ServiceModel.Syndication" Dynamic="Required All" />
</Library>
在 </Application>
之后和 </Directives>
之前
我正在尝试将 XmlReader 加载到 System.ServiceModel.Syndication.SyndicationFeed,它仅在发布模式下导致异常,但在调试模式下工作
加载代码
using (var xmlReader = XmlReader.Create(new StringReader(stringXML), new XmlReaderSettings { Async = true, IgnoreWhitespace = true, IgnoreComments = true }))
{
System.ServiceModel.Syndication.SyndicationFeed feed = System.ServiceModel.Syndication.SyndicationFeed.Load(xmlReader);
}
异常
System.Reflection.MissingRuntimeArtifactException: ‘Cannot retrieve a MethodInfo for this delegate because the method it targeted (System.ServiceModel.Syndication.SyndicationFeedFormatter.DefaultUriParser(XmlUriData, Uri&)) was not enabled for metadata using the Dynamic attribute. For more information, please visit https://go.microsoft.com/fwlink/?LinkID=616868’
将此代码添加到 Default.rd.xml 文件可解决问题
<Library Name="SyndicationFeed">
<Assembly Name="System.ServiceModel.Syndication" Activate="Required All" Browse="Required All" Serialize="Required All" Dynamic="Required All" />
<Namespace Name="System.ServiceModel.Syndication" Dynamic="Required All" />
</Library>
在 </Application>
之后和 </Directives>