<相依性>項目 (ClickOnce 部署)<dependency> element (ClickOnce deployment)

識別要安裝,應用程式的版本和應用程式資訊清單的位置。Identifies the version of the application to install, and the location of the application manifest.

語法Syntax


      <dependency>
   <dependentAssembly
      preRequisite
      visible
      dependencyType
      codeBase
      size
   >
      <assemblyIdentity
         name
         version
         publicKeyToken
         processorArchitecture
         language
         type
      />
      <hash>
         <dsig:Transforms>
            <dsig:Transform
                Algorithm
            />
         </dsig:Transforms>
         <dsig:DigestMethod />
         <dsig:DigestValue>
         </dsig:DigestValue>
      </hash>

   </dependentAssembly>
</dependency>

元素和屬性Elements and attributes

dependency是必要元素。The dependency element is required. 它沒有任何屬性。It has no attributes. 部署資訊清單可以有多個dependency項目。A deployment manifest can have multiple dependency elements.

dependency項目通常表示主應用程式的相依性組件內含ClickOnceClickOnce應用程式。The dependency element usually expresses dependencies for the main application on assemblies contained within a ClickOnceClickOnce application. 如果 Main.exe 應用程式會使用稱為 DotNetAssembly.dll 的組件,該組件必須在相依性一節中所列。If your Main.exe application consumes an assembly called DotNetAssembly.dll, then that assembly must be listed in a dependency section. 相依性,不過,也可以表示其他類型的相依性,例如倚賴特定版本的 common language runtime 中,在全域組件快取 (GAC) 中的組件或 COM 物件上。Dependency, however, can also express other types of dependencies, such as dependencies on a specific version of the common language runtime, on an assembly in the global assembly cache (GAC), or on a COM object. 因為它是一種自動部署技術,ClickOnceClickOnce無法起始下載和安裝這些類型的相依性,但它不會防止應用程式執行如果一或多個指定的相依性不存在。Because it is a no-touch deployment technology, ClickOnceClickOnce cannot initiate download and installation of these types of dependencies, but it does prevent the application from running if one or more of the specified dependencies do not exist.

dependentAssemblydependentAssembly

必要項。Required. 這個項目包含assemblyIdentity項目。This element contains the assemblyIdentity element. 下表顯示的屬性dependentAssembly支援。The following table shows the attributes the dependentAssembly supports.

屬性Attribute 描述Description
preRequisite 選擇性。Optional. 指定這個組件應該已經存在於 GAC。Specifies that this assembly should already exist in the GAC. 有效值為 truefalseValid values are true and false. 如果true,和指定的組件不存在於 GAC、 應用程式無法執行。If true, and the specified assembly does not exist in the GAC, the application fails to run.
visible 選擇性。Optional. 識別最上層應用程式身分識別,包括其相依性。Identifies the top-level application identity, including its dependencies. 在內部使用ClickOnceClickOnce來管理應用程式存放區和啟用。Used internally by ClickOnceClickOnce to manage application storage and activation.
dependencyType 必要項。Required. 此相依性和應用程式之間的關係。The relationship between this dependency and the application. 有效值為:Valid values are:

- install.- install. 元件代表目前的應用程式是個別安裝。Component represents a separate installation from the current application.
- preRequisite.- preRequisite. 目前的應用程式需要的元件。Component is required by the current application.
codebase 選擇性。Optional. 應用程式資訊清單的完整路徑。The full path to the application manifest.
size 選擇性。Optional. 應用程式資訊清單,以位元組為單位的大小。The size of the application manifest, in bytes.

assemblyIdentityassemblyIdentity

必要項。Required. 這個元素是 dependentAssembly 元素的子項。This element is a child of the dependentAssembly element. 內容assemblyIdentity必須如所述相同ClickOnceClickOnce應用程式資訊清單。The content of assemblyIdentity must be the same as described in the ClickOnceClickOnce application manifest. 下表顯示的屬性assemblyIdentity項目。The following table shows the attributes of the assemblyIdentity element.

屬性Attribute 描述Description
Name 必要項。Required. 識別應用程式的名稱。Identifies the name of the application.
Version 必要項。Required. 指定的版本號碼的應用程式,以下列格式: major.minor.build.revisionSpecifies the version number of the application, in the following format: major.minor.build.revision
publicKeyToken 必要項。Required. 指定 16 個字元的十六進位字串,表示簽署的應用程式或組件之公開金鑰的 sha-1 雜湊最後 8 個位元組。Specifies a 16-character hexadecimal string that represents the last 8 bytes of the SHA-1 hash of the public key under which the application or assembly is signed. 用來登入的公用金鑰必須是 2048 位元或更高。The public key used to sign must be 2048 bits or greater.
processorArchitecture 必要項。Required. 指定微處理器。Specifies the microprocessor. 有效值x86用於 32 位元 Windows 和IA64的 64 位元 Windows。The valid values are x86 for 32-bit Windows and IA64 for 64-bit Windows.
Language 選擇性。Optional. 識別組件的兩個組件語言代碼。Identifies the two part language codes of the assembly. 例如,EN-US,代表針對英文 (美國)。For example, EN-US, which stands for English (U.S.). 預設為 neutralThe default is neutral. 此元素為asmv2命名空間。This element is in the asmv2 namespace.
type 選擇性。Optional. 針對回溯相容性 Windows-並存安裝技術。For backwards compatibility with Windows side-by-side install technology. 唯一允許的值是win32The only allowed value is win32.

雜湊hash

hash項目是選用的子系file項目。The hash element is an optional child of the file element. hash 項目沒有任何屬性。The hash element has no attributes.

ClickOnceClickOnce 使用應用程式中的所有檔案的演算法雜湊做為安全性檢查,以確保沒有任何檔案已在部署後變更。uses an algorithmic hash of all the files in an application as a security check to ensure that none of the files were changed after deployment. 如果hash就不會包含項目,將不會執行這項檢查。If the hash element is not included, this check will not be performed. 因此,省略hash不建議項目。Therefore, omitting the hash element is not recommended.

dsig:Transformsdsig:Transforms

dsig:Transforms項目是必要的子系hash項目。The dsig:Transforms element is a required child of the hash element. dsig:Transforms 項目沒有任何屬性。The dsig:Transforms element has no attributes.

dsig:Transformdsig:Transform

dsig:Transform項目是必要的子系dsig:Transforms項目。The dsig:Transform element is a required child of the dsig:Transforms element. 下表顯示的屬性dsig:Transform項目。The following table shows the attributes of the dsig:Transform element.

屬性Attribute 描述Description
Algorithm 用來計算此檔案的摘要演算法。The algorithm used to calculate the digest for this file. 目前所使用的唯一值ClickOnceClickOnceurn:schemas-microsoft-com:HashTransforms.IdentityCurrently the only value used by ClickOnceClickOnce is urn:schemas-microsoft-com:HashTransforms.Identity.

dsig:DigestMethoddsig:DigestMethod

dsig:DigestMethod項目是必要的子系hash項目。The dsig:DigestMethod element is a required child of the hash element. 下表顯示的屬性dsig:DigestMethod項目。The following table shows the attributes of the dsig:DigestMethod element.

屬性Attribute 描述Description
Algorithm 用來計算此檔案的摘要演算法。The algorithm used to calculate the digest for this file. 目前所使用的唯一值ClickOnceClickOncehttp://www.w3.org/2000/09/xmldsig#sha1Currently the only value used by ClickOnceClickOnce is http://www.w3.org/2000/09/xmldsig#sha1.

dsig:DigestValuedsig:DigestValue

dsig:DigestValue項目是必要的子系hash項目。The dsig:DigestValue element is a required child of the hash element. dsig:DigestValue 項目沒有任何屬性。The dsig:DigestValue element has no attributes. 它的值是計算的雜湊指定的檔案。Its text value is the computed hash for the specified file.

備註Remarks

部署資訊清單通常會有單一assemblyIdentity可識別的名稱和版本的應用程式資訊清單的項目。Deployment manifests typically have a single assemblyIdentity element that identifies the name and version of the application manifest.

範例Example

下列程式碼範例所示dependency中的項目ClickOnceClickOnce部署資訊清單。The following code example shows a dependency element in a ClickOnceClickOnce deployment manifest.

<!-- Identify the assembly dependencies -->
<dependency>
  <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="MyApplication.exe" size="16384">
    <assemblyIdentity name="MyApplication" version="0.0.0.0" cultural="neutral" processorArchitecture="msil" />
    <hash>
      <dsig:Transforms>
        <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
      </dsig:Transforms>
      <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
       <dsig:DigestValue>YzXYZJAvj9pgAG3y8jXUjC7AtHg=</dsig:DigestValue>
    </hash>
  </dependentAssembly>
</dependency>

範例Example

下列程式碼範例會指定已安裝在 GAC 中的組件相依性。The following code example specifies a dependency on an assembly already installed in the GAC.

<dependency>
  <dependentAssembly dependencyType="preRequisite" allowDelayedBinding="true">
    <assemblyIdentity name="GACAssembly" version="1.0.0.0" language="neutral" processorArchitecture="msil" />
  </dependentAssembly>
</dependency>

範例Example

下列程式碼範例會指定特定版本的通用語言執行平台上的相依性。The following code example specifies a dependency on a specific version of the common language runtime.

<dependency>
  <dependentAssembly dependencyType="preRequisite" allowDelayedBinding="true">
    <assemblyIdentity name="Microsoft.Windows.CommonLanguageRuntime" version="2.0.50215.0" />
  </dependentAssembly>
</dependency>

範例Example

下列程式碼範例會指定作業系統相依性。The following code example specifies an operating system dependency.

<dependency>
   <dependentOS supportUrl="http://www.microsoft.com" description="Microsoft Windows Operating System">
      <osVersionInfo>
         <os majorVersion="4" minorVersion="10" />
      </osVersionInfo>
   </dependentOS>
</dependency>

另請參閱See also