SuppressUnmanagedCodeSecurityAttribute クラス

定義

マネージド コードを、スタック ウォークなしでアンマネージド コードに呼び出せるようにします。 このクラスは継承できません。

public ref class SuppressUnmanagedCodeSecurityAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Delegate | System.AttributeTargets.Interface | System.AttributeTargets.Method, AllowMultiple=true, Inherited=false)]
public sealed class SuppressUnmanagedCodeSecurityAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface | System.AttributeTargets.Method, AllowMultiple=true, Inherited=false)]
public sealed class SuppressUnmanagedCodeSecurityAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Delegate | System.AttributeTargets.Interface | System.AttributeTargets.Method, AllowMultiple=true, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class SuppressUnmanagedCodeSecurityAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Delegate | System.AttributeTargets.Interface | System.AttributeTargets.Method, AllowMultiple=true, Inherited=false)>]
type SuppressUnmanagedCodeSecurityAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface | System.AttributeTargets.Method, AllowMultiple=true, Inherited=false)>]
type SuppressUnmanagedCodeSecurityAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Delegate | System.AttributeTargets.Interface | System.AttributeTargets.Method, AllowMultiple=true, Inherited=false)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type SuppressUnmanagedCodeSecurityAttribute = class
    inherit Attribute
Public NotInheritable Class SuppressUnmanagedCodeSecurityAttribute
Inherits Attribute
継承
SuppressUnmanagedCodeSecurityAttribute
属性

注釈

重要

部分的に信頼されたコードはサポートされなくなりました。 この属性は、.NET Core には影響しません。

注意事項

この属性は細心の注意を払って使用してください。 使用が正しくないと、セキュリティ上の弱点が生じる可能性があります。

この属性は、実行時のセキュリティ チェックのパフォーマンス低下を招くことなく、ネイティブ コードを呼び出すメソッドに適用できます。 アンマネージド コードを呼び出すときに実行されるスタック ウォークは実行時に省略されるため、パフォーマンスが大幅に低下します。 クラスでこの属性を使用すると、含まれるすべてのメソッドに適用されます。

一般に、マネージド コードがアンマネージ コード (PInvoke または COM によるネイティブ コードへの相互運用) を呼び出すたびに、すべての呼び出し元がこれを許可するために必要なアクセス許可を持っていることを確認するためのアクセス許可が必要 UnmanagedCode です。 この明示的な属性を適用することで、開発者は実行時に需要を抑制できます。 開発者は、アンマネージド コードへの移行が他の方法で十分に保護されていることを保証する責任を負う必要があります。 アクセス許可の UnmanagedCode 要求は、リンク時に引き続き発生します。 たとえば、関数 A が関数 B を呼び出し、関数 B が で SuppressUnmanagedCodeSecurityAttributeマークされている場合、関数 A は Just-In-Time コンパイル時にアンマネージド コードのアクセス許可をチェックされますが、実行時にはチェックされません。

この属性は、PInvoke メソッド (または PInvoke メソッドを含むクラス) または相互運用呼び出しが行われるインターフェイスの定義に適用される場合にのみ有効です。 他のすべてのコンテキストでは無視されます。

この属性は、アンマネージ コードを介してシステム リソースへのアクセスを提供するクラスを実装する場合に役立ちます。 アンマネージ コードにアクセスするアクセス許可を持たないコードは、この属性を持つクラスを呼び出してアンマネージ コードにアクセスできます。 これは、この属性を持つクラスのライターがクラスをセキュリティで保護するようにプログラムしている場合にのみ安全です。 そうでない場合、この属性は危険であり、それを使用するコードが誤用される可能性があります。

これは宣言型のセキュリティ属性ではなく、通常の属性です (ではなく、 SecurityAttributeからAttribute派生します)。

コンストラクター

SuppressUnmanagedCodeSecurityAttribute()

SuppressUnmanagedCodeSecurityAttribute クラスの新しいインスタンスを初期化します。

プロパティ

TypeId

派生クラスで実装されると、この Attribute の一意の識別子を取得します。

(継承元 Attribute)

メソッド

Equals(Object)

このインスタンスが、指定されたオブジェクトと等価であるかどうかを示す値を返します。

(継承元 Attribute)
GetHashCode()

このインスタンスのハッシュ コードを返します。

(継承元 Attribute)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IsDefaultAttribute()

派生クラスでオーバーライドされるとき、このインスタンスの値が派生クラスの既定値であるかどうかを示します。

(継承元 Attribute)
Match(Object)

派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。

(継承元 Attribute)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

オブジェクトの型情報を取得します。この情報はインターフェイスの型情報の取得に使用できます。

(継承元 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。

(継承元 Attribute)

適用対象

こちらもご覧ください