HostProtectionResource 列舉

定義

指定功能的分類,如果方法或類別叫用這些功能,則可能對主機有害。Specifies categories of functionality potentially harmful to the host if invoked by a method or class.

此列舉具有 FlagsAttribute 個屬性允許以位元方式合併其成員值。

public enum class HostProtectionResource
[System.Flags]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum HostProtectionResource
type HostProtectionResource = 
Public Enum HostProtectionResource
繼承
HostProtectionResource
屬性

欄位

All 511

公開 (Expose) 所有主機資源。Exposes all host resources.

ExternalProcessMgmt 4

可能建立或終結其他處理序。Might create or destroy other processes.

ExternalThreading 16

建立或管理除了其自身之外的執行緒,這些執行緒可能對主機有害。Creates or manipulates threads other than its own, which might be harmful to the host.

MayLeakOnAbort 256

如果未受安全控制代碼或某些確保資源釋放的其他方法保護,可能會導致終止時的資源流失。Might cause a resource leak on termination, if not protected by a safe handle or some other means of ensuring the release of resources.

None 0

未公開任何主機資源。Exposes no host resources.

SecurityInfrastructure 64

公開安全性基礎結構。Exposes the security infrastructure.

SelfAffectingProcessMgmt 8

可能結束目前的處理序,終止伺服器。Might exit the current process, terminating the server.

SelfAffectingThreading 32

以只影響使用者程式碼的方式管理執行緒。Manipulates threads in a way that only affects user code.

SharedState 2

公開可能在執行緒之間共用的狀態。Exposes state that might be shared between threads.

Synchronization 1

公開同步處理。Exposes synchronization.

UI 128

公開使用者介面。Exposes the user interface.

範例

下列程式碼範例示範如何使用HostProtectionResource HostProtectionAttribute具有屬性的列舉。The following code example shows the use of the HostProtectionResource enumeration with the HostProtectionAttribute attribute. 這個範例是針對HostProtectionAttribute類別提供之較大範例的一部分。This example is part of a larger example provided for the HostProtectionAttribute class.

// 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屬性所使用。This enumeration is used by the HostProtectionAttribute attribute.

適用於