Type.IsSecurityTransparent 屬性

定義

取得值,這個值表示目前類型在目前信任層級上是否為透明,因此無法執行重要作業。Gets a value that indicates whether the current type is transparent at the current trust level, and therefore cannot perform critical operations.

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

屬性值

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

備註

如果這個屬性true傳回IsSecurityCritical ,和IsSecuritySafeCritical屬性false會傳回。If this property returns true, the IsSecurityCritical and IsSecuritySafeCritical properties return false.

IsSecurityCritical、和屬性IsSecurityTransparent會在其目前的信任層級(由 common language runtime (CLR)所決定)上,報告類型的透明度層級。 IsSecuritySafeCriticalThe 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). 使用這些屬性會比檢查組件及其類型的安全性註釋、檢查目前的信任層級,以及嘗試複製執行階段規則更簡單。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.

適用於

另請參閱