HostProtectionResource Enumeración
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Precaución
Code Access Security is not supported or honored by the runtime.
Especifica categorías de funcionalidad potencialmente dañina para el host si lo invoca un método o una clase.
Esta enumeración admite una combinación bit a bit de sus valores de miembro.
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
- Herencia
- Atributos
Nombre | Valor | Description |
---|---|---|
All | 511 | Expone todos los recursos del host. |
ExternalProcessMgmt | 4 | Podría crear o destruir otros procesos. |
ExternalThreading | 16 | Crea o manipula los subprocesos distintos de los suyos propios, lo que podría ser dañino para el host. |
MayLeakOnAbort | 256 | Si no está protegido por un controlador seguro o algún otro medio para garantizar la liberación de recursos, se podría producir una pérdida de recursos al finalizar. |
None | 0 | No expone ningún recurso del host. |
SecurityInfrastructure | 64 | Expone la infraestructura de seguridad. |
SelfAffectingProcessMgmt | 8 | Podría salir del proceso actual, finalizando el servidor. |
SelfAffectingThreading | 32 | Manipula los subprocesos de un modo que sólo afecta al código del usuario. |
SharedState | 2 | Expone el estado que se podría compartir entre los subprocesos. |
Synchronization | 1 | Expone la sincronización. |
UI | 128 | Expone la interfaz de usuario. |
En el ejemplo de código siguiente se muestra el uso de la HostProtectionResource enumeración con el HostProtectionAttribute atributo . Este ejemplo forma parte de un ejemplo más grande proporcionado para la HostProtectionAttribute clase .
// 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
Advertencia
La seguridad de acceso del código (CAS) ha quedado en desuso en todas las versiones de .NET Framework y .NET. Las versiones recientes de .NET no respetan las anotaciones de CAS y generan errores si se usan API relacionadas con CAS. Los desarrolladores deben buscar medios alternativos para realizar tareas de seguridad.
El atributo usa HostProtectionAttribute esta enumeración.
Produto | Versións (Obsoleto) |
---|---|
.NET | (6, 7, 8, 9) |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0 |
Windows Desktop | 3.0, 3.1 (5, 6, 7, 8, 9) |
Comentarios de .NET
.NET é un proxecto de código aberto. Selecciona unha ligazón para ofrecer comentarios: