使用權限檢視工具 (Permview.exe)

使用權限檢視工具是用來檢視組件 (Assembly) 所要求的最小、選擇性和拒絕的使用權限集合。您可以選擇性使用 Permview.exe 來檢視組件所用的所有宣告式安全性。Permview.exe 只能在 .NET Framework 1.0 和 1.1 版中使用。

permview [/output filename] [/decl] manifestfile

參數

引數 描述

manifestfile

包含組件資訊清單 (Assembly Manifest) 的檔案。資訊清單可以是獨立檔案或被併入到可移植的執行檔 (PE)。這個檔案的副檔名通常會是 .exe 或 .dll,但也可以是 .scr 或 .ocx。

選項 描述

/decl

顯示所有宣告性安全性於 manifestfile 所指定的組件、類別和組件的方法層級。這包含使用權限要求以及需要、判斷提示 (Assert) 和所有其他可以被宣告性地套用的安全動作。它並沒有參考其他連結至指定組件的組件。

/h[elp]

顯示工具的命令語法和選項。

/output filename

將輸出寫入指定的檔案。預設值是顯示輸出至主控台 (Console)。

/?

顯示工具的命令語法和選項。

備註

開發人員可以使用 Permview.exe 來驗證已正確套用使用權限要求至程式碼中。此外,使用者可以執行 Permview.exe 來判斷使用權限是需要執行的組件。例如,如果您執行某個 Managed 可執行檔並且發生「System.Security.Policy.PolicyException: 無法取得必要的使用權限」的錯誤時,您可以使用 Permview.exe 來判斷您的可執行檔中程式碼,在執行前必須具有的使用權限。

範例

下列命令會將 myAssembly.exe 組件所要求的使用權限顯示到主控台。

permview myAssembly.exe

如果 myAssembly.exe 包含 FullTrust 的最小要求,將會顯示下列輸出。

Microsoft (R) .NET Framework Permission Request Viewer.  Version 1.0.2204.18 Copyright (C) Microsoft Corp. 1998-2000

minimal permission set:
<PermissionSet class="System.Security.PermissionSet" version ="1">
   <Unrestricted/>
</PermissionSet>

optional permission set:
   Not specified

refused permission set:
   Not specified

下列命令會將 myAssembly.exe 組件上的所有宣告式安全性顯示到主控台。這個命令顯示方法層級安全需求。

permview /decl myAssembly.exe

即顯示下列輸出。

Microsoft (R) .NET Framework Permission Request Viewer.  
Version 1.0.2204.18 Copyright (C) Microsoft Corp. 1998-2000

Assembly RequestMinimum permission set:
<PermissionSet class="System.Security.PermissionSet" version ="1">
   <Unrestricted/>
</PermissionSet>

Method A::myMethod() LinktimeCheck permission set:
<PermissionSet class="System.Security.PermissionSet" version="1">
   <Permission class="System.Security.Permissions.ReflectionPermission,
      mscorlib, Ver=1.0.2204.2, Loc='', SN=03689116d3a4ae33" 
      version="1">
      <MemberAccess/>
   </Permission>
</PermissionSet>

下列命令會將 myAssembly.exe 組件要求的使用權限寫入到 myOutputFile 檔案。

permview /output myOutputFile myAssembly.exe 

請參閱

參考

.NET Framework 工具

概念

要求使用權限
宣告式安全性
要求
使用 Assert 方法
使用 Deny 方法
使用 PermitOnly 方法

其他資源

Common Language Runtime 中的組件