MethodBuilder.AddDeclarativeSecurity メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > MethodBuilder.AddDeclarativeSecurity メソッドの意味・解説 

MethodBuilder.AddDeclarativeSecurity メソッド

このメソッド宣言セキュリティ追加します

名前空間: System.Reflection.Emit
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub AddDeclarativeSecurity ( _
    action As SecurityAction, _
    pset As PermissionSet _
)
Dim instance As MethodBuilder
Dim action As SecurityAction
Dim pset As PermissionSet

instance.AddDeclarativeSecurity(action, pset)
public void AddDeclarativeSecurity (
    SecurityAction action,
    PermissionSet pset
)
public:
void AddDeclarativeSecurity (
    SecurityAction action, 
    PermissionSet^ pset
)
public void AddDeclarativeSecurity (
    SecurityAction action, 
    PermissionSet pset
)
public function AddDeclarativeSecurity (
    action : SecurityAction, 
    pset : PermissionSet
)

パラメータ

action

実行するセキュリティ アクション (DemandAssert など)。

pset

アクション適用する一連のアクセス許可

例外例外
例外種類条件

ArgumentOutOfRangeException

action無効です。RequestMinimumRequestOptional、および RequestRefuse無効です。

InvalidOperationException

外側の型が CreateType を使用して作成されています。

または

アクセス許可セット pset に、既に AddDeclarativeSecurity によって追加されたアクション含まれています。

または

現在のメソッドでは、IsGenericMethod プロパティtrue ですが、IsGenericMethodDefinition プロパティfalse です。

ArgumentNullException

psetnull 参照 (Visual Basic では Nothing) です。

使用例使用例

AddDeclarativeSecurity使用して無制限アクセス許可メソッド呼び出し元に対して要求する方法については、次のコード例参照してください

' myModBuilder is an instance of ModuleBuilder.
' Note that for the use of PermissionSet and SecurityAction,
' the namespaces System.Security and System.Security.Permissions
' should be included.
Dim myTypeBuilder As TypeBuilder = myModBuilder.DefineType("MyType",
 _
                        TypeAttributes.Public)

Dim myMethod1 As MethodBuilder = myTypeBuilder.DefineMethod("MyMethod",
 _
                       MethodAttributes.Public, _
                       GetType(Integer), _
                       New Type() {GetType(Integer),
 GetType(Integer)})

Dim myMethodPermissions As New
 PermissionSet(PermissionState.Unrestricted)

myMethod1.AddDeclarativeSecurity(SecurityAction.Demand, myMethodPermissions)

// myModBuilder is an instance of ModuleBuilder.
// Note that for the use of PermissionSet and SecurityAction,
// the namespaces System.Security and System.Security.Permissions
// should be included.

TypeBuilder myTypeBuilder = myModBuilder.DefineType("MyType",
                    TypeAttributes.Public);

                    
MethodBuilder myMethod1 = myTypeBuilder.DefineMethod("MyMethod",
                    MethodAttributes.Public, 
                    typeof(int),
                    new Type[] 
                    {typeof(int), typeof(int)});
    

PermissionSet myMethodPermissions = new PermissionSet(
            PermissionState.Unrestricted);

myMethod1.AddDeclarativeSecurity(SecurityAction.Demand,
                 myMethodPermissions);

// myModBuilder is an instance of ModuleBuilder.
// Note that for the use of PermissionSet and SecurityAction,
// the namespaces System::Security and System::Security::Permissions
// should be included.

TypeBuilder^ myTypeBuilder = myModBuilder->DefineType( "MyType",
                             TypeAttributes::Public );

array<Type^>^ temp0 = {int::typeid, int::typeid};
MethodBuilder^ myMethod1 = myTypeBuilder->DefineMethod( "MyMethod",
                           MethodAttributes::Public,
                           int::typeid, temp0 );

PermissionSet^ myMethodPermissions = gcnew PermissionSet(
                                     PermissionState::Unrestricted );

myMethod1->AddDeclarativeSecurity( SecurityAction::Demand,
                                   myMethodPermissions );
// myModBuilder is an instance of ModuleBuilder.
// Note that for the use of PermissionSet and SecurityAction,
// the namespaces System.Security and System.Security.Permissions
// should be included.
TypeBuilder myTypeBuilder = myModBuilder.DefineType("MyType",
    TypeAttributes.Public);
MethodBuilder myMethod1 = myTypeBuilder.DefineMethod("MyMethod",
    MethodAttributes.Public,int.class.ToType()
,
    new Type[] { int.class.ToType(),
 int.class.ToType() });
PermissionSet myMethodPermissions =
    new PermissionSet(PermissionState.Unrestricted);
myMethod1.AddDeclarativeSecurity(SecurityAction.Demand,
    myMethodPermissions);
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MethodBuilder クラス
MethodBuilder メンバ
System.Reflection.Emit 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

MethodBuilder.AddDeclarativeSecurity メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



MethodBuilder.AddDeclarativeSecurity メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS