Type.IsSecuritySafeCritical 屬性

定義

取得值,這個值表示目前類型在目前信任層級上是否為安全性安全關鍵,也就是說,它是否能執行重要作業並由安全性透明的程式碼存取。Gets a value that indicates whether the current type is security-safe-critical at the current trust level; that is, whether it can perform critical operations and can be accessed by transparent code.

public:
 virtual property bool IsSecuritySafeCritical { bool get(); };
public virtual bool IsSecuritySafeCritical { get; }
member this.IsSecuritySafeCritical : bool
Public Overridable ReadOnly Property IsSecuritySafeCritical As Boolean

屬性值

Boolean

如果目前型別在目前信任層級上為安全性安全關鍵,則為 true,如果為安全性關鍵或安全性透明,則為 falsetrue if the current type is security-safe-critical at the current trust level; false if it is security-critical or transparent.

備註

IsSecurityCriticalIsSecuritySafeCritical 和屬性會 IsSecurityTransparent 在目前的信任層級報告類型的透明度層級,由 common LANGUAGE runtime (CLR) 所決定。The IsSecurityCritical, IsSecuritySafeCritical, and IsSecurityTransparent properties report the transparency level of the type at its current trust level, as determined by the common language runtime (CLR). 下表顯示這些屬性的組合:The combinations of these properties are shown in the following table:

安全性層級Security level IsSecurityCriticalIsSecurityCritical IsSecuritySafeCriticalIsSecuritySafeCritical IsSecurityTransparentIsSecurityTransparent
重大Critical true false false
安全關鍵Safe critical true true false
透明Transparent false false true

使用這些屬性會比檢查組件及其類型的安全性註釋、檢查目前的信任層級,以及嘗試複製執行階段規則更簡單。Using these properties is much simpler than examining the security annotations of an assembly and its types, checking the current trust level, and attempting to duplicate the runtime's rules.

重要

針對部分信任元件,這個屬性的值取決於元件目前的信任層級。For partial-trust assemblies, the value of this property depends on the current trust level of the assembly. 如果將元件載入至部分信任的應用程式域 (例如,加入至沙箱應用程式域) ,則執行時間會忽略元件的安全性注釋。If the assembly is loaded into a partially trusted application domain (for example, into a sandboxed application domain), then the runtime ignores the security annotations of the assembly. 元件及其所有類型都會被視為透明。The assembly and all its types are treated as transparent. 只有當元件載入到完全信任的應用程式 (域時,執行時間才會注意部分信任元件的安全性附注,例如,在桌面應用程式的預設應用程式域中) 。The runtime pays attention to the security annotations of a partial-trust assembly only when that assembly is loaded into a fully trusted application domain (for example, into the default application domain of a desktop application). 相反地,信任的元件 (亦即,安裝在全域組件快取) 中的強式名稱元件,一律會以完全信任方式載入,而不論應用程式域的信任層級為何,因此其目前的信任層級一律為完全信任。By contrast, a trusted assembly (that is, a strong-named assembly that is installed in the global assembly cache) is always loaded with full trust regardless of the trust level of the application domain, so its current trust level is always fully trusted. 您可以使用和屬性,判斷目前的元件和應用程式域信任層級 Assembly.IsFullyTrusted AppDomain.IsFullyTrustedYou can determine the current trust levels of assemblies and application domains by using the Assembly.IsFullyTrusted and AppDomain.IsFullyTrusted properties.

如需反映和透明度的詳細資訊,請參閱 反映的安全性考慮For more information about reflection and transparency, see Security Considerations for Reflection. 如需透明度的詳細資訊,請參閱 安全性變更For information about transparency, see Security Changes.

適用於

另請參閱