HostProtectionResource Enumeração

Definição

Cuidado

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

Especifica as categorias de funcionalidade potencialmente prejudicial ao host quando invocado por uma classe ou um método.

Essa enumeração dá suporte a uma combinação bit a bit dos valores de membro.

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
Herança
HostProtectionResource
Atributos

Campos

All 511

Expõe todos os recursos de host.

ExternalProcessMgmt 4

Pode criar ou destruir outros processos.

ExternalThreading 16

Cria ou manipula threads que não os próprios, que podem ser prejudiciais ao host.

MayLeakOnAbort 256

Pode causar uma perda de recursos no encerramento, se não estiver protegido por um identificador seguro ou algum outro meio de garantir a liberação de recursos.

None 0

Não expõe nenhum recurso de host.

SecurityInfrastructure 64

Expõe a infraestrutura de segurança.

SelfAffectingProcessMgmt 8

Pode sair do processo atual, encerrando o servidor.

SelfAffectingThreading 32

Manipula os threads de modo a afetar apenas o código do usuário.

SharedState 2

Expõe estado que pode ser compartilhado entre threads.

Synchronization 1

Expõe a sincronização.

UI 128

Expõe a interface do usuário.

Exemplos

O exemplo de código a seguir mostra o uso da HostProtectionResource enumeração com o HostProtectionAttribute atributo. Este exemplo faz parte de um exemplo maior fornecido para a HostProtectionAttribute classe.

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

Comentários

Essa enumeração é usada pelo HostProtectionAttribute atributo.

Aplica-se a