MethodBuilder.AddDeclarativeSecurity メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As MethodBuilder Dim action As SecurityAction Dim pset As PermissionSet instance.AddDeclarativeSecurity(action, pset)

例外の種類 | 条件 |
---|---|
ArgumentOutOfRangeException | action が無効です。RequestMinimum、RequestOptional、および RequestRefuse が無効です。 |
InvalidOperationException | 外側の型が CreateType を使用して作成されています。 または アクセス許可セット pset に、既に AddDeclarativeSecurity によって追加されたアクションが含まれています。 または 現在のメソッドでは、IsGenericMethod プロパティは true ですが、IsGenericMethodDefinition プロパティが false です。 |
ArgumentNullException | pset が null 参照 (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);

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- MethodBuilder.AddDeclarativeSecurity メソッドのページへのリンク