I'm trying to load XmlReader to System.ServiceModel.Syndication.SyndicationFeed and it cause an exception only in release mode but work in debug mode
the loading code
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);
}
the exception
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’
and the xml content https://mspoweruser.com/feed
adding this code to the Default.rd.xml file fixes the problem
<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>
after </Application>
and before </Directives>