HostProtectionResource Wyliczenie

Definicja

Przestroga

Code Access Security is not supported or honored by the runtime.

Określa kategorie funkcji potencjalnie szkodliwe dla hosta w przypadku wywołania przez metodę lub klasę.

To wyliczenie obsługuje bitową kombinację jego wartości składowych.

public enum class HostProtectionResource
[System.Flags]
public enum HostProtectionResource
[System.Flags]
[System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public enum HostProtectionResource
[System.Flags]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum HostProtectionResource
[<System.Flags>]
type HostProtectionResource = 
[<System.Flags>]
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type HostProtectionResource = 
[<System.Flags>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type HostProtectionResource = 
Public Enum HostProtectionResource
Dziedziczenie
HostProtectionResource
Atrybuty

Pola

All 511

Uwidacznia wszystkie zasoby hosta.

ExternalProcessMgmt 4

Może tworzyć lub niszczyć inne procesy.

ExternalThreading 16

Tworzy lub manipuluje wątkami innymi niż własne, które mogą być szkodliwe dla hosta.

MayLeakOnAbort 256

Może spowodować wyciek zasobów po zakończeniu, jeśli nie jest chroniony przez bezpieczny uchwyt lub inne sposoby zapewnienia zwolnienia zasobów.

None 0

Uwidacznia brak zasobów hosta.

SecurityInfrastructure 64

Uwidacznia infrastrukturę zabezpieczeń.

SelfAffectingProcessMgmt 8

Może zakończyć bieżący proces, kończąc serwer.

SelfAffectingThreading 32

Manipuluje wątkami w sposób, który wpływa tylko na kod użytkownika.

SharedState 2

Uwidacznia stan, który może być współużytkowany między wątkami.

Synchronization 1

Uwidacznia synchronizację.

UI 128

Uwidacznia interfejs użytkownika.

Przykłady

Poniższy przykład kodu przedstawia użycie wyliczenia HostProtectionResource z atrybutem HostProtectionAttribute . Ten przykład jest częścią większego przykładu udostępnionego HostProtectionAttribute dla klasy.

// Use the enumeration flags to indicate that this method exposes shared state and 
// self-affecting process management.
// Either of the following attribute statements can be used to set the 
// resource flags.
// Exit the sample when an exception is thrown.

[HostProtection(SharedState=true,SelfAffectingProcessMgmt=true)]
[HostProtection(Resources=HostProtectionResource::SharedState|
HostProtectionResource::SelfAffectingProcessMgmt)]
static void Exit( String^ Message, int Code )
{
   Console::WriteLine( "\nFAILED: {0} {1}", Message, Code );
   Environment::ExitCode = Code;
   Environment::Exit( Code );
}
// Use the enumeration flags to indicate that this method exposes 
// shared state and self-affecting process management.
// Either of the following attribute statements can be used to set the
// resource flags.
[HostProtectionAttribute(SharedState = true, 
    SelfAffectingProcessMgmt = true)]
[HostProtectionAttribute(Resources = HostProtectionResource.SharedState |
     HostProtectionResource.SelfAffectingProcessMgmt)]
private static void Exit(string Message, int Code)
{
    // Exit the sample when an exception is thrown.
    Console.WriteLine("\nFAILED: " + Message + " " + Code.ToString());
    Environment.ExitCode = Code;
    Environment.Exit(Code);
}
' Use the enumeration flags to indicate that this method exposes 
' shared state and self-affecting process management.
' Either of the following attribute statements can be used to set the 
' resource flags.
<HostProtectionAttribute(SharedState := True, _
    SelfAffectingProcessMgmt := True), _
    HostProtectionAttribute( _
    Resources := HostProtectionResource.SharedState Or _
    HostProtectionResource.SelfAffectingProcessMgmt)> _
Private Shared Sub [Exit](ByVal Message As String, ByVal Code As Integer)

    ' Exit the sample when an exception is thrown.
    Console.WriteLine((ControlChars.Lf & "FAILED: " & Message & " " & _
        Code.ToString()))
    Environment.ExitCode = Code
    Environment.Exit(Code)
End Sub

Uwagi

Przestroga

Zabezpieczenia dostępu do kodu (CAS) zostały przestarzałe we wszystkich wersjach .NET Framework i .NET. Najnowsze wersje platformy .NET nie honorują adnotacji CAS i generują błędy, jeśli są używane interfejsy API związane z usługą CAS. Deweloperzy powinni szukać alternatywnych sposobów wykonywania zadań zabezpieczeń.

To wyliczenie jest używane przez HostProtectionAttribute atrybut .

Dotyczy