Nóta
Aðgangur að þessari síðu krefst heimildar. Þú getur prófað aðskrá þig inn eða breyta skráasöfnum.
Aðgangur að þessari síðu krefst heimildar. Þú getur prófað að breyta skráasöfnum.
.NET Core and .NET 5 and later versions eliminate the concept of the global assembly cache (GAC) that was present in .NET Framework. To help steer developers away from these APIs, some GAC-related APIs are marked as obsolete, starting in .NET 5. Using these APIs generates warning SYSLIB0005 at compile time.
The following GAC-related APIs are marked obsolete:
-
Libraries and apps should not use the GlobalAssemblyCache API to make determinations about runtime behavior, as it always returns
falsein .NET Core and .NET 5+.
Workarounds
If your application queries the GlobalAssemblyCache property, consider removing the call. If you use the GlobalAssemblyCache value to choose between an "assembly in the GAC"-flow vs. an "assembly not in the GAC"-flow at runtime, reconsider whether the flow still makes sense for a .NET 5+ application.
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 SYSLIB0005
// Code that uses obsolete API.
// ...
// Re-enable the warning.
#pragma warning restore SYSLIB0005
To suppress all the SYSLIB0005 warnings in your project, add a <NoWarn> property to your project file.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
...
<NoWarn>$(NoWarn);SYSLIB0005</NoWarn>
</PropertyGroup>
</Project>
For more information, see Suppress warnings.