Nóta
Teastaíonn údarú chun rochtain a fháil ar an leathanach seo. Is féidir leat triail a bhaint as shíniú isteach nó eolairí a athrú.
Teastaíonn údarú chun rochtain a fháil ar an leathanach seo. Is féidir leat triail a bhaint as eolairí a athrú.
The Graphics.GetContextInfo() method that takes no arguments is marked as obsolete, starting in .NET 6. Using it in code generates warning SYSLIB0016 at compile time.
For more information, see https://github.com/dotnet/runtime/issues/47880.
Workarounds
For better performance and fewer allocations, use the Graphics.GetContextInfo overloads that accept arguments:
- System.Drawing.Graphics.GetContextInfo(PointF)
- System.Drawing.Graphics.GetContextInfo(PointF, Region)
Suppress a warning
If you must use the obsolete APIs, you can suppress the warning in code or in your project file.
To suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the warning.
// Disable the warning.
#pragma warning disable SYSLIB0016
// Code that uses obsolete API.
// ...
// Re-enable the warning.
#pragma warning restore SYSLIB0016
To suppress all the SYSLIB0016 warnings in your project, add a <NoWarn> property to your project file.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
...
<NoWarn>$(NoWarn);SYSLIB0016</NoWarn>
</PropertyGroup>
</Project>
For more information, see Suppress warnings.