共用方式為


SecurityManager.SecurityEnabled 屬性

定義

警告

此 API 現已淘汰。

警告

Because security can no longer be turned off permanently, setting the SecurityEnabled property no longer has any effect. Reading the property will still indicate whether security has been turned off temporarily.

警告

Because security can no longer be turned off, the SecurityEnabled property no longer has any effect.

警告

The security manager cannot be turned off on MS runtime

取得或設定值,指出是否啟用安全性。

public:
 static property bool SecurityEnabled { bool get(); void set(bool value); };
[System.Obsolete]
public static bool SecurityEnabled { get; set; }
public static bool SecurityEnabled { get; set; }
[System.Obsolete("Because security can no longer be turned off permanently, setting the SecurityEnabled property no longer has any effect. Reading the property will still indicate whether security has been turned off temporarily.")]
public static bool SecurityEnabled { get; set; }
[System.Obsolete("Because security can no longer be turned off, the SecurityEnabled property no longer has any effect.")]
public static bool SecurityEnabled { get; set; }
[System.Obsolete("The security manager cannot be turned off on MS runtime")]
public static bool SecurityEnabled { get; set; }
[<System.Obsolete>]
member this.SecurityEnabled : bool with get, set
member this.SecurityEnabled : bool with get, set
[<System.Obsolete("Because security can no longer be turned off permanently, setting the SecurityEnabled property no longer has any effect. Reading the property will still indicate whether security has been turned off temporarily.")>]
member this.SecurityEnabled : bool with get, set
[<System.Obsolete("Because security can no longer be turned off, the SecurityEnabled property no longer has any effect.")>]
member this.SecurityEnabled : bool with get, set
[<System.Obsolete("The security manager cannot be turned off on MS runtime")>]
member this.SecurityEnabled : bool with get, set
Public Shared Property SecurityEnabled As Boolean

屬性值

Boolean

如果啟用安全性,則為 true,否則為 false

屬性

例外狀況

呼叫此方法的程式碼沒有 ControlPolicy

備註

Caspol.exe (程式碼存取安全性原則工具會使用此屬性)

-security``-s () 選項,以關閉程式碼型安全性。

SecurityEnabled 提供讓系統管理員停用代碼存取安全性的方法。 停用程式碼存取安全性時,所有的程式碼存取需求都會成功。 實際上,這會授與所有程式碼 FullTrust 。 停用程式碼存取安全性會略過安全性系統,讓程式碼的執行效能可能比授 FullTrust 與所有程式碼的對等安全性原則還要好。 此屬性不會停用角色型安全性;因此, PrincipalPermission 需求不會受到影響。

警告

停用程式碼存取安全性會讓系統容易受惡意程式碼的攻擊,如病毒和破壞程式。 停用程式碼存取安全性不會以任何方式自動封鎖 Managed 程式碼執行。 它只會讓 Managed 程式碼在沒有程式碼存取安全性系統限制的情況下執行,而且應該只謹慎執行。 只有在採取其他安全性措施來協助保護系統安全性時,才應該關閉安全性以提升額外的效能。 其他安全性措施的範例,包括從公用網路中斷連結、用實際方法保全電腦等等。

呼叫之前 SavePolicy ,此屬性的變更不會保存在登錄中。 在登錄中保存新進程之前,不會受到變更的影響。 在執行中的進程中變更這個屬性的值不一定會以預期的方式變更狀態。 若要確保變更生效,您必須呼叫 SavePolicy 並啟動新的程式。

適用於