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

公開 (Expose) 所有主機資源。

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 列舉。

適用於