Share via


HostProtectionResource Enum

Definisi

Perhatian

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

Menentukan kategori fungsionalitas yang berpotensi berbahaya bagi host jika dipanggil oleh metode atau kelas.

Enumerasi ini mendukung kombinasi bitwise dari nilai yang termasuk di dalamnya.

public enum class 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]
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}")>]
type HostProtectionResource = 
[<System.Flags>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type HostProtectionResource = 
[<System.Flags>]
type HostProtectionResource = 
Public Enum HostProtectionResource
Warisan
HostProtectionResource
Atribut

Bidang

All 511

Mengekspos semua sumber daya host.

ExternalProcessMgmt 4

Mungkin membuat atau menghancurkan proses lain.

ExternalThreading 16

Membuat atau memanipulasi utas selain utasnya sendiri, yang mungkin berbahaya bagi host.

MayLeakOnAbort 256

Dapat menyebabkan kebocoran sumber daya pada penghentian, jika tidak dilindungi oleh handel yang aman atau beberapa cara lain untuk memastikan rilis sumber daya.

None 0

Tidak mengekspos sumber daya host.

SecurityInfrastructure 64

Mengekspos infrastruktur keamanan.

SelfAffectingProcessMgmt 8

Mungkin keluar dari proses saat ini, mengakhiri server.

SelfAffectingThreading 32

Memanipulasi utas dengan cara yang hanya memengaruhi kode pengguna.

SharedState 2

Mengekspos status yang mungkin dibagikan di antara utas.

Synchronization 1

Mengekspos sinkronisasi.

UI 128

Mengekspos antarmuka pengguna.

Contoh

Contoh kode berikut menunjukkan penggunaan HostProtectionResource enumerasi dengan HostProtectionAttribute atribut . Contoh ini adalah bagian dari contoh yang lebih besar yang disediakan untuk HostProtectionAttribute kelas .

// 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

Keterangan

Perhatian

Keamanan Akses Kode (CAS) tidak digunakan lagi di semua versi .NET Framework dan .NET. Versi terbaru .NET tidak mematuhi anotasi CAS dan menghasilkan kesalahan jika API terkait CAS digunakan. Pengembang harus mencari cara alternatif untuk menyelesaikan tugas keamanan.

Enumerasi ini digunakan oleh HostProtectionAttribute atribut .

Berlaku untuk