RSAKeyValue causes CryptographicException

If an XML signature includes , the following exception can occur.

System.Security.Cryptography.CryptographicException: Root element must be KeyValue
element in namepsace
at System.Security.Cryptography.Xml.RSAKeyValue.LoadXml(XmlElement value)
at System.Security.Cryptography.Xml.KeyInfo.LoadXml(XmlElement value)
at System.Security.Cryptography.Xml.Signature.LoadXml(XmlElement value)
at System.Security.Cryptography.Xml.SignedXml.LoadXml(XmlElement value)
at ComponentSpace.Saml2.XmlSecurity.Signature.XmlSignature.Verify(XmlElement signedElement

Typically XML signatures include an rather than an so in most cases this bug isn’t triggered.
The bug is in System.Security.Cryptography.Xml.
The fix is part of the .NET Core 2.1 release.
Refer to:
The workaround is to include the following, or a later release, in the application’s project file.