Type.IsSecuritySafeCritical Type.IsSecuritySafeCritical Type.IsSecuritySafeCritical Type.IsSecuritySafeCritical Property


取得值,這個值表示目前類型在目前信任層級上是否為安全性安全關鍵,也就是說,它是否能執行重要作業並由安全性透明的程式碼存取。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.

 virtual property bool IsSecuritySafeCritical { bool get(); };
public virtual bool IsSecuritySafeCritical { get; }
member this.IsSecuritySafeCritical : bool
Public Overridable ReadOnly Property IsSecuritySafeCritical As 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
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.