Type.IsSecurityCritical Type.IsSecurityCritical Type.IsSecurityCritical Type.IsSecurityCritical Property

定義

取得值,這個值表示目前類型在目前信任層級上是否為安全性關鍵或安全性安全關鍵,因而可以執行重要的作業。Gets a value that indicates whether the current type is security-critical or security-safe-critical at the current trust level, and therefore can perform critical operations.

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

屬性值

如果目前類型在目前信任層級上為安全性關鍵或安全性安全關鍵,則為 true,如果是安全性透明,則為 falsetrue if the current type is security-critical or security-safe-critical at the current trust level; false if it is 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
CriticalCritical 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.IsFullyTrustedAppDomain.IsFullyTrusted屬性。You 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.

適用於

另請參閱