ReflectionPermissionFlag 列舉

定義

警告

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

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

此列舉有 FlagsAttribute 屬性,因此其成員值可進行位元組合。

public enum class ReflectionPermissionFlag
[System.Flags]
public enum ReflectionPermissionFlag
[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 ReflectionPermissionFlag
[System.Flags]
[System.Serializable]
public enum ReflectionPermissionFlag
[System.Flags]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum ReflectionPermissionFlag
[<System.Flags>]
type ReflectionPermissionFlag = 
[<System.Flags>]
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type ReflectionPermissionFlag = 
[<System.Flags>]
[<System.Serializable>]
type ReflectionPermissionFlag = 
[<System.Flags>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type ReflectionPermissionFlag = 
Public Enum ReflectionPermissionFlag
繼承
ReflectionPermissionFlag
屬性

欄位

AllFlags 7

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

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 0

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

ReflectionEmit 4

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

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 中的新旗標。This flag is new in the .NET Framework 2.0 SP1.

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. 這個範例是針對類別提供的較大範例的一部分 ReflectionPermissionThis 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)

備註

和類別會使用這個列舉 ReflectionPermission ReflectionPermissionAttributeThis enumeration is used by the ReflectionPermission and ReflectionPermissionAttribute classes. 如果未 ReflectionPermission 授與,則會允許所有類型和成員進行反映,但只允許在可見的類型和成員上使用調用作業。If 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.

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

重要

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

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

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

適用於

另請參閱