System.Security.SecurityContext is marked obsolete

SecurityContext is marked obsolete with a custom diagnostic ID. Using any SecurityContext APIs generates warning SYSLIB0003 at compile time.


Suppressing the default obsoletion diagnostic ID, which is CS0618 for the C# compiler, does not suppress the warnings that the compiler generates when these APIs are used.

Old behavior

Prior to .NET 6, the SecurityContext type was not marked obsolete, however, all of its public members throw a PlatformNotSupportedException at run time.

New behavior

Starting in .NET 6, the SecurityContext is marked obsolete.

Version introduced

.NET 6 RC 1

Type of breaking change

This change can affect source compatibility.

Reason for change

All of the public members of SecurityContext throw a PlatformNotSupportedException at run time. The SecurityContext is part of Code access security (CAS), which is an unsupported legacy technology.

Remove any use of these APIs from your code.

Affected APIs

See also