英語で読む

次の方法で共有


HostProtectionResource 列挙型

定義

注意事項

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

メソッドまたはクラスによって呼び出された場合にホストに害を及ぼす可能性がある機能のカテゴリを指定します。

この列挙体は、メンバー値のビットごとの組み合わせをサポートしています。

C#
[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
C#
[System.Flags]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum HostProtectionResource
C#
[System.Flags]
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 一部です。

C#
// 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);
}

注釈

注意事項

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

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

適用対象

製品 バージョン (廃止)
.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)