<dependency>元素(ClickOnce 應用程式)<dependency> element (ClickOnce application)

識別應用程式所需的平臺或元件相依性。Identifies a platform or assembly dependency that is required for the application.

語法Syntax


      <dependency>
   <dependentOS
      supportURL
      description
   >
      <osVersionInfo>
         <os
            majorVersion
            minorVersion
            buildNumber
            servicePackMajor
            servicePackMinor
            productType
            suiteType
         />
      </osVersionInfo>
   </dependentOS>
   <dependentAssembly
      dependencyType
      allowDelayedBinding
      group
      codeBase
      size
   >
      <assemblyIdentity
         name
         version
         processorArchitecture
         language
      >
         <hash>
            <dsig:Transforms>
               <dsig:Transform
                  Algorithm
            />
            </dsig:Transforms>
            <dsig:DigestMethod />
            <dsig:DigestValue>
            </dsig:DigestValue>
    </hash>

      </assemblyIdentity>
   </dependentAssembly>
</dependency>

元素和屬性Elements and attributes

需要dependency元素。The dependency element is required. 同一個應用程式資訊清單dependency中可能有多個實例。There may be multiple instances of dependency in the same application manifest.

dependency元素沒有屬性,且包含下列子專案。The dependency element has no attributes, and contains the following child elements.

dependentOSdependentOS

選擇性。Optional. osVersionInfo包含元素。Contains the osVersionInfo element. 和專案互斥:一個或dependency另一個必須存在於元素,但不能同時為兩者。 dependentAssembly dependentOSThe dependentOS and dependentAssembly elements are mutually exclusive: one or the other must exist for a dependency element, but not both.

dependentOS支援下列屬性。dependentOS supports the following attributes.

屬性Attribute 描述Description
supportUrl 選擇性。Optional. 指定相依平臺的支援 URL。Specifies a support URL for the dependent platform. 如果找到必要的平臺,則會向使用者顯示此 URL。This URL is shown to the user if the required platform is found.
description 選擇性。Optional. 以人類看得懂的形式,描述由dependentOS元素所描述的作業系統。Describes, in human-readable form, the operating system described by the dependentOS element.

osVersionInfoosVersionInfo

必要項。Required. 這個元素是 dependentOS 元素的子項,並包含 os 元素。This element is a child of the dependentOS element and contains the os element. 這個元素沒有屬性。This element has no attributes.

osos

必要項。Required. 這個元素是 osVersionInfo 元素的子項。This element is a child of the osVersionInfo element. 這個項目具有下列屬性。This element has the following attributes.

屬性Attribute 描述Description
majorVersion 必要項。Required. 指定 OS 的主要版本號碼。Specifies the major version number of the OS.
minorVersion 必要項。Required. 指定 OS 的次要版本號碼。Specifies the minor version number of the OS.
buildNumber 必要項。Required. 指定 OS 的組建編號。Specifies the build number of the OS.
servicePackMajor 必要項。Required. 指定 OS 的 Service Pack 主要號碼。Specifies the service pack major number of the OS.
servicePackMinor 選擇性。Optional. 指定 OS 的 Service Pack 次要號碼。Specifies the service pack minor number of the OS.
productType 選擇性。Optional. 識別產品類型值。Identifies the product type value. 有效值為 serverworkstationdomainControllerValid values are server, workstation, and domainController. 例如,針對 Windows 2000 Professional,此屬性值為workstationFor example, for Windows 2000 Professional, this attribute value is workstation.
suiteType 選擇性。Optional. 識別系統上可用的產品套件,或系統的設定類型。Identifies a product suite available on the system, or the system's configuration type. 有效值為 backofficebladedatacenterenterprisehomeprofessionalsmallbusinesssmallbusinessRestrictedterminalValid values are backoffice, blade, datacenter, enterprise, home, professional, smallbusiness, smallbusinessRestricted, and terminal. 例如,針對 Windows 2000 Professional,此屬性值為professionalFor example, for Windows 2000 Professional, this attribute value is professional.

dependentAssemblydependentAssembly

選擇性。Optional. assemblyIdentity包含元素。Contains the assemblyIdentity element. 和專案互斥:一個或dependency另一個必須存在於元素,但不能同時為兩者。 dependentAssembly dependentOSThe dependentOS and dependentAssembly elements are mutually exclusive: one or the other must exist for a dependency element, but not both.

dependentAssembly具有下列屬性。dependentAssembly has the following attributes.

屬性Attribute 描述Description
dependencyType 必要項。Required. 指定相依性類型。Specifies the dependency type. 有效值為 preprequisiteinstallValid values are preprequisite and install. 元件會當做ClickOnceClickOnce應用程式的一部分進行安裝。 installAn install assembly is installed as part of the ClickOnceClickOnce application. 元件必須存在於全域組件快取(GAC)中, ClickOnceClickOnce應用程式才能安裝。 prerequisiteA prerequisite assembly must be present in the global assembly cache (GAC) before the ClickOnceClickOnce application can install.
allowDelayedBinding 必要項。Required. 指定是否可以在執行時間以程式設計方式載入元件。Specifies whether the assembly can be loaded programmatically at run time.
group 選擇性。Optional. 如果屬性設定為install,則會指定只視需要安裝的已命名元件群組。 dependencyTypeIf the dependencyType attribute is set to install, designates a named group of assemblies that only install on demand. 如需詳細資訊,請參閱逐步解說:依需求使用設計工具以 ClickOnce 部署 API 下載組件For more information, see Walkthrough: Downloading Assemblies on Demand with the ClickOnce Deployment API Using the Designer.

如果設定為frameworkdependencyType且屬性設定為prerequisite,則會將元件指定為 .NET Framework 的一部分。If set to framework and the dependencyType attribute is set to prerequisite, designates the assembly as part of the .NET Framework. 在 .NET Framework 4 和更新版本上安裝時,不會檢查此元件的全域 assembly 快取(GAC)。The global assemby cache (GAC) is not checked for this assembly when installing on .NET Framework 4 and later versions.
codeBase 當屬性設定dependencyTypeinstall時,這是必要的。Required when the dependencyType attribute is set to install. 相依元件的路徑。The path to the dependent assembly. 可以是絕對路徑,或相對於資訊清單之程式碼基底的路徑。May be either an absolute path, or a path relative to the manifest's code base. 此路徑必須是有效的 URI,組件資訊清單才會是有效的。This path must be a valid URI in order for the assembly manifest to be valid.
size 當屬性設定dependencyTypeinstall時,這是必要的。Required when the dependencyType attribute is set to install. 相依元件的大小(以位元組為單位)。The size of the dependent assembly, in bytes.

assemblyIdentityassemblyIdentity

必要項。Required. 這個元素是 dependentAssembly 元素的子項,並具有下列屬性。This element is a child of the dependentAssembly element and has the following attributes.

屬性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 選擇性。Optional. 指定16個字元的十六進位字串,表示用來簽署應用程式或SHA-1元件之公開金鑰雜湊值的最後8個位元組。Specifies a 16-character hexadecimal string that represents the last 8 bytes of the SHA-1 hash value of the public key under which the application or assembly is signed. 用來簽署目錄的公開金鑰必須是2048位或更多。The public key used to sign the catalog must be 2048 bits or more.
processorArchitecture 選擇性。Optional. 指定處理器。Specifies the processor. 有效的值x86為32位 windows 和I64 64 位 windows。The valid values are x86 for 32-bit Windows and I64 for 64-bit Windows.
language 選擇性。Optional. 識別元件的兩個部分語言代碼,例如 EN-US。Identifies the two part language codes, such as EN-US, of the assembly.

雜湊hash

元素是assemblyIdentity元素的選擇性子專案。 hashThe hash element is an optional child of the assemblyIdentity 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. 如果未包含此元素,則不會執行此檢查。hashIf the hash element is not included, this check will not be performed. 因此,不建議hash省略元素。Therefore, omitting the hash element is not recommended.

dsig:Transformsdsig:Transforms

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

dsig:Transformdsig:Transform

元素是dsig:Transforms元素的必要子系。 dsig:TransformThe dsig:Transform element is a required child of the dsig:Transforms element. dsig:Transform 項目具有下列屬性。The dsig:Transform element has the following attributes.

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

dsig:DigestMethoddsig:DigestMethod

元素是hash元素的必要子系。 dsig:DigestMethodThe dsig:DigestMethod element is a required child of the hash element. dsig:DigestMethod 項目具有下列屬性。The dsig:DigestMethod element has the following attributes.

屬性Attribute 描述Description
Algorithm 用來計算此檔案摘要的演算法。The algorithm used to calculate the digest for this file. 目前所使用ClickOnceClickOnce的唯一值是http://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

元素是hash元素的必要子系。 dsig:DigestValueThe 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

應用程式所使用的所有元件都必須有dependency對應的元素。All assemblies used by your application must have a corresponding dependency element. 相依元件不包含必須在全域組件快取中預先安裝為平臺元件的元件。Dependent assemblies do not include assemblies that must be preinstalled in the global assembly cache as platform assemblies.

範例Example

下列ClickOnceClickOnce程式碼範例說明dependency應用程式資訊清單中的元素。The following code example illustrates dependency elements in a ClickOnceClickOnce application manifest. 這個程式碼範例是針對ClickOnce 應用程式資訊清單主題提供之較大範例的一部分。This code example is part of a larger example provided for the ClickOnce Application Manifest topic.

<dependency>
  <dependentOS>
    <osVersionInfo>
      <os
        majorVersion="4"
        minorVersion="10"
        buildNumber="0"
        servicePackMajor="0" />
    </osVersionInfo>
  </dependentOS>
</dependency>
<dependency>
  <dependentAssembly
    dependencyType="preRequisite"
    allowDelayedBinding="true">
    <assemblyIdentity
      name="Microsoft.Windows.CommonLanguageRuntime"
      version="4.0.20506.0" />
  </dependentAssembly>
</dependency>

<dependency>
  <dependentAssembly
    dependencyType="install"
    allowDelayedBinding="true"
    codebase="MyApplication.exe"
    size="4096">
    <assemblyIdentity
      name="MyApplication"
      version="1.0.0.0"
      language="neutral"
      processorArchitecture="x86" />
    <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>DpTW7RzS9IeT/RBSLj54vfTEzNg=</dsig:DigestValue>
    </hash>
  </dependentAssembly>
</dependency>

另請參閱See also