HostProtectionResource Перечисление

Определение

Внимание!

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

Определяет категории функциональных возможностей для узла, которые могут быть потенциально опасны, если они вызываются методом или классом.

Это перечисление поддерживает побитовую комбинацию значений его членов.

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
Наследование
HostProtectionResource
Атрибуты

Поля

All 511

Предоставляет все ресурсы узла.

ExternalProcessMgmt 4

Может создавать или уничтожать другие процессы.

ExternalThreading 16

Создает потоки или управляет потоками, не являющимися его собственными, и которые могут быть вредны для узла.

MayLeakOnAbort 256

Может быть причиной утечки ресурсов при прерывании, если они не защищены безопасными дескрипторами или другими средствами, обеспечивающими освобождение ресурсов.

None 0

Не предоставляет ресурсы узла.

SecurityInfrastructure 64

Предоставляет инфраструктуру безопасности.

SelfAffectingProcessMgmt 8

Может привести к выходу из текущего процесса, прервав серверный процесс.

SelfAffectingThreading 32

Управляет потоками таким образом, что воздействует только на код пользователя.

SharedState 2

Предоставляет состояние, которое может быть совместно использовано несколькими потоками.

Synchronization 1

Обеспечивает синхронизацию.

UI 128

Предоставляет пользовательский интерфейс.

Примеры

В следующем примере кода показано использование перечисления HostProtectionResource с атрибутом HostProtectionAttribute . Этот пример является частью более крупного примера, предоставленного HostProtectionAttribute для класса.

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

Комментарии

Это перечисление используется атрибутом HostProtectionAttribute .

Применяется к