HostProtectionResource Výčet

Definice

Upozornění

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

Určuje kategorie funkcí potenciálně škodlivé pro hostitele, pokud je vyvolána metodou nebo třídou.

Tento výčet podporuje bitové kombinace hodnot jeho členů.

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
Dědičnost
HostProtectionResource
Atributy

Pole

All 511

Zveřejňuje všechny prostředky hostitele.

ExternalProcessMgmt 4

Může vytvářet nebo zničit jiné procesy.

ExternalThreading 16

Vytváří nebo manipuluje s vlákny jinými než vlastními, což může být škodlivé pro hostitele.

MayLeakOnAbort 256

Může způsobit únik prostředků při ukončení, pokud není chráněný bezpečným popisovačem nebo jiným způsobem zajištění uvolnění prostředků.

None 0

Zpřístupňuje žádné hostitelské prostředky.

SecurityInfrastructure 64

Zpřístupňuje infrastrukturu zabezpečení.

SelfAffectingProcessMgmt 8

Může ukončit aktuální proces a ukončit server.

SelfAffectingThreading 32

Manipuluje s vlákny způsobem, který ovlivňuje pouze uživatelský kód.

SharedState 2

Zveřejňuje stav, který může být sdílen mezi vlákny.

Synchronization 1

Zveřejňuje synchronizaci.

UI 128

Zpřístupňuje uživatelské rozhraní.

Příklady

Následující příklad kódu ukazuje použití HostProtectionResource výčtu s atributem HostProtectionAttribute . Tento příklad je součástí většího příkladu zadaného HostProtectionAttribute pro třídu.

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

Poznámky

Tento výčet používá HostProtectionAttribute atribut.

Platí pro