SYSLIB0033: Rfc2898DeriveBytes.CryptDeriveKey is obsolete
The Rfc2898DeriveBytes.CryptDeriveKey(String, String, Int32, Byte[]) method is marked as obsolete, starting in .NET 6. Using this API in code generates warning SYSLIB0033 at compile time.
Workaround
Use PasswordDeriveBytes.CryptDeriveKey(String, String, Int32, Byte[]) instead.
Suppress warnings
It's recommended that you use an available workaround whenever possible. However, if you cannot change your code, you can suppress warnings through a #pragma directive or a <NoWarn> project setting. If you must use the obsolete APIs and the SYSLIB0XXX diagnostic does not surface as an error, you can suppress the warning in code or in your project file.
To suppress the warnings in code:
// Disable the warning.
#pragma warning disable SYSLIB0001
// Code that uses obsolete API.
//...
// Re-enable the warning.
#pragma warning restore SYSLIB0001
To suppress the warnings in a project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<!-- NoWarn below suppresses SYSLIB0001 project-wide -->
<NoWarn>$(NoWarn);SYSLIB0001</NoWarn>
<!-- To suppress multiple warnings, you can use multiple NoWarn elements -->
<NoWarn>$(NoWarn);SYSLIB0002</NoWarn>
<NoWarn>$(NoWarn);SYSLIB0003</NoWarn>
<!-- Alternatively, you can suppress multiple warnings by using a semicolon-delimited list -->
<NoWarn>$(NoWarn);SYSLIB0001;SYSLIB0002;SYSLIB0003</NoWarn>
</PropertyGroup>
</Project>
Note
Suppressing warnings in this way only disables the obsoletion warnings you specify. It doesn't disable any other warnings, including obsoletion warnings with different diagnostic IDs.
الملاحظات
إرسال الملاحظات وعرضها المتعلقة بـ