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

注釈

注意事項

コード アクセス セキュリティ (CAS) は、.NET Framework と .NET のすべてのバージョンで非推奨になりました。 最近のバージョンの .NET では、CAS 関連の API が使われている場合、CAS の注釈は使われず、エラーが発生します。 開発者は、代わりの手段を見つけてセキュリティ タスクを実現する必要があります。

この列挙は、 属性によって HostProtectionAttribute 使用されます。

適用対象