netstandard2.0
NuGet 包版本 9.0.0 到 9.0.2 的 System.Security.Cryptography.Pkcs
生成包含 .NET Framework 中不存在的 API。 从 .NET Framework 上运行的 .NET Standard 库调用这些 API 将引发 MissingMemberException。 这些成员被错误地包含在包的 9.0.3 版本中,并已经被移除。
已引入的版本
.NET 9
以前的行为
在项目目标System.Security.Cryptography.Pkcs
中引用netstandard2.0
版本 9.0.0 时,引用CmsSigner.PrivateKey属性时编译会成功。 但是,如果库在 .NET Framework 上运行,访问该属性将触发一个 MissingMemberException。
新行为
访问任何已删除的成员现在会导致编译失败,而不是运行时失败。
破坏性变更的类型
这是 源不兼容 的更改。
更改原因
由于 NuGet 包的生成方式发生了更改,因此意外包含成员。 由于这些成员不能在 .NET Framework 上工作,因此不应将其列为 .NET Standard 2.0 可用的成员。
建议的措施
如果需要这些附加成员,请专门为包含这些成员的 TFM 进行编译,例如 net8.0
。
受影响的 API
- CmsSigner
- System.Security.Cryptography.Pkcs.CmsSigner.PrivateKey
- System.Security.Cryptography.Pkcs.CmsSigner.SignaturePadding
- System.Security.Cryptography.Pkcs.ContentInfo.GetContentType(ReadOnlySpan<Byte>)
- System.Security.Cryptography.Pkcs.EnvelopedCms.Decode(ReadOnlySpan<Byte>)
- System.Security.Cryptography.Pkcs.EnvelopedCms.Decrypt(RecipientInfo, AsymmetricAlgorithm)
- System.Security.Cryptography.Pkcs.SignedCms.AddCertificate(X509Certificate2)
- System.Security.Cryptography.Pkcs.SignedCms.Decode(ReadOnlySpan<Byte>)
- System.Security.Cryptography.Pkcs.SignedCms.RemoveCertificate(X509Certificate2)
- System.Security.Cryptography.Pkcs.SignerInfo.AddUnsignedAttribute(AsnEncodedData)
- System.Security.Cryptography.Pkcs.SignerInfo.SignatureAlgorithm
- System.Security.Cryptography.Pkcs.SignerInfo.GetSignature()
- System.Security.Cryptography.Pkcs.SignerInfo.RemoveUnsignedAttribute(AsnEncodedData)
- System.Security.Cryptography.Pkcs.SubjectIdentifier.MatchesCertificate(X509Certificate2)