ReflectionPermissionFlag ReflectionPermissionFlag ReflectionPermissionFlag ReflectionPermissionFlag Enum

定義

指定許可的 System.ReflectionSystem.Reflection.Emit 命名空間使用。Specifies the permitted use of the System.Reflection and System.Reflection.Emit namespaces.

此列舉具有 FlagsAttribute 個屬性允許以位元方式合併其成員值。

public enum class ReflectionPermissionFlag
[System.Flags]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum ReflectionPermissionFlag
type ReflectionPermissionFlag = 
Public Enum ReflectionPermissionFlag
繼承
ReflectionPermissionFlagReflectionPermissionFlagReflectionPermissionFlagReflectionPermissionFlag
屬性

欄位

AllFlags AllFlags AllFlags AllFlags 7

設定 TypeInformationMemberAccessReflectionEmitTypeInformation , MemberAccess, and ReflectionEmit are set. AllFlags 不包含 RestrictedMemberAccessAllFlags does not include RestrictedMemberAccess.

MemberAccess MemberAccess MemberAccess MemberAccess 2

不論授權集為何,所有成員上都允許引動作業。Invocation operations on all members are allowed, regardless of grant set. 如果這個旗標沒有設定,則只有在可見成員上允許引動作業。If this flag is not set, invocation operations are allowed only on visible members.

NoFlags NoFlags NoFlags NoFlags 0

允許型別和成員的列舉型別。Enumeration of types and members is allowed. 可見型別和成員上允許引動作業。Invocation operations are allowed on visible types and members.

ReflectionEmit ReflectionEmit ReflectionEmit ReflectionEmit 4

允許發出偵錯符號。Emitting debug symbols is allowed. .NET Framework 2.0 Service Pack 1.NET Framework 2.0 Service Pack 1 開始,不再需要具有此旗標才能發出程式碼。Beginning with the .NET Framework 2.0 Service Pack 1.NET Framework 2.0 Service Pack 1, this flag is no longer required to emit code.

RestrictedMemberAccess RestrictedMemberAccess RestrictedMemberAccess RestrictedMemberAccess 8

受限制的成員存取是為部分信任的程式碼所提供的。Restricted member access is provided for partially trusted code. 只有在部分信任程式碼的授權集包含了組件 (包含所要存取之非公用型別和成員) 授權集中的所有權限時,部分信任程式碼才可以存取非公用型別和成員。Partially trusted code can access nonpublic types and members, but only if the grant set of the partially trusted code includes all permissions in the grant set of the assembly that contains the nonpublic types and members being accessed. 這個旗標在 .NET Framework 2.0 SP1.NET Framework 2.0 SP1 中是新的。This flag is new in the .NET Framework 2.0 SP1.NET Framework 2.0 SP1.

TypeInformation TypeInformation TypeInformation TypeInformation 1

這個旗標已過時。This flag is obsolete. 不需要旗標即可列舉型別和成員以及檢查其中繼資料。No flags are necessary to enumerate types and members and to examine their metadata. 請改用 NoFlagsUse NoFlags instead.

範例

下列範例示範如何使用ReflectionPermissionFlag列舉來初始化ReflectionPermission類別的新實例, 以代表執行受限成員存取權的許可權。The following example shows how to use the ReflectionPermissionFlag enumeration to initialize a new instance of the ReflectionPermission class that represents the right to perform restricted member access. 這個範例是針對ReflectionPermission類別提供之較大範例的一部分。This example is part of a larger example that is provided for the ReflectionPermission class.

如需說明如何搭配使用 RestrictedMemberAccess 旗標與網際網路程式碼的範例, 請參閱逐步解說:在部分信任案例中發出程式碼。For an example that shows how to use the RestrictedMemberAccess flag with Internet code, see Walkthrough: Emitting Code in Partial Trust Scenarios.

ReflectionPermission restrictedMemberAccessPerm = new ReflectionPermission(ReflectionPermissionFlag.RestrictedMemberAccess);
Dim restrictedMemberAccessPerm As New ReflectionPermission(ReflectionPermissionFlag.RestrictedMemberAccess)

備註

這個列舉是由ReflectionPermissionReflectionPermissionAttribute類別使用。This enumeration is used by the ReflectionPermission and ReflectionPermissionAttribute classes. 如果未授與, 則在所有類型和成員上都允許反映, 但只有可見的類型和成員才允許調用作業。 ReflectionPermissionIf no ReflectionPermission is granted, reflection is allowed on all types and members, but invocation operations are allowed only on visible types and members. 如需詳細資訊,請參閱反映的安全性考量For more information, see Security Considerations for Reflection.

警告

因為ReflectionPermission可以提供私用類別成員的存取權, 所以我們建議ReflectionPermission您只使用RestrictedMemberAccess旗標來授與網際網路程式碼, 而不是使用任何其他旗標。Because ReflectionPermission can provide access to private class members, we recommend that you grant ReflectionPermission to Internet code only with the RestrictedMemberAccess flag, and not with any other flags.

.NET Framework 2.0 SP1.NET Framework 2.0 SP1 中已開始使用 RestrictedMemberAccess 旗標。The RestrictedMemberAccess flag is introduced in the .NET Framework 2.0 SP1.NET Framework 2.0 SP1. 若要使用此旗標, 您的.NET Framework 3.5.NET Framework 3.5應用程式應以或更新版本為目標。To use this flag, your application should target the .NET Framework 3.5.NET Framework 3.5 or later.

重要

AllFlags不包含RestrictedMemberAccess旗標。AllFlags does not include the RestrictedMemberAccess flag. 若要取得包含這個列舉中所有旗標的遮罩, 您必須搭配使用AllFlagsRestrictedMemberAccess的組合。To get a mask that includes all flags in this enumeration, you must use the combination of AllFlags with RestrictedMemberAccess.

從開始.NET Framework 2.0 SP1.NET Framework 2.0 SP1 ReflectionEmit , 除非發出 debug 符號, 否則不再需要旗標來發出程式碼。Starting with the .NET Framework 2.0 SP1.NET Framework 2.0 SP1, the ReflectionEmit flag is no longer required to emit code, unless debug symbols are emitted. 若要使用這項功能, 您的.NET Framework 3.5.NET Framework 3.5應用程式應以或更新版本為目標。To use this feature, your application should target the .NET Framework 3.5.NET Framework 3.5 or later.

從開始.NET Framework 2.0.NET Framework 2.0 TypeInformation , 已不再需要旗標來反映非公用類型和成員; 旗標已標記為過時。Starting with the .NET Framework 2.0.NET Framework 2.0, the TypeInformation flag is no longer required to reflect on nonpublic types and members; the flag has been marked obsolete.

適用於

另請參閱