在 ClickOnce 部署中指定個別必要條件的支援 URL

ClickOnce 部署可以測試用戶端電腦上必須可供執行 ClickOnce 應用程式的一些必要條件。 這些相依性包括必要的 .NET Framework 最低版本、作業系統的版本,以及必須在全域組件快取 (GAC) 中預先安裝的任何組件。 不過,ClickOnce 本身無法安裝任何這些必要條件;如果找不到必要條件,它只會停止安裝並顯示一個對話方塊,說明安裝失敗的原因。

安裝必要條件的方法有兩種。 您可以使用啟動載入器應用程式來安裝它們。 或者,您也可以指定個別必要條件的支援 URL (如果找不到必要條件,則會在對話方塊上向使用者顯示此 URL)。 該 URL 所參考的頁面可以包含安裝所需必要條件的指示的連結。 如果應用程式未指定個別必要條件的支援 URL,ClickOnce 會顯示整個應用程式的部署資訊清單中指定的支援 URL (如果已定義)。

雖然 Visual Studio、Mage.exeMageUI.exe 都可以用來產生 ClickOnce 部署,但這些工具都不直接支援指定個別必要條件的支援 URL。 本文件說明如何修改部署的應用程式資訊清單和部署資訊清單,以包含這些支援 URL。

指定個別必要條件的支援 URL

  1. 在文字編輯器中開啟 ClickOnce 應用程式的應用程式資訊清單 (.manifest 檔案)。

  2. 針對作業系統必要條件,將 supportUrl 屬性新增至 dependentOS 元素中:

     <dependency>
        <dependentOS supportUrl="http://www.adatum.com/MyApplication/wrongOSFound.htm">
          <osVersionInfo>
            <os majorVersion="5" minorVersion="1" buildNumber="2600" servicePackMajor="0" servicePackMinor="0" />
          </osVersionInfo>
        </dependentOS>
      </dependency>
    
  3. 如需特定通用語言執行平台版本的必要條件,請將 supportUrl 屬性新增至指定通用語言執行平台相依性的 dependentAssembly 項目中:

      <dependency>
        <dependentAssembly dependencyType="preRequisite" allowDelayedBinding="true" supportUrl=" http://www.adatum.com/MyApplication/wrongClrVersionFound.htm">
          <assemblyIdentity name="Microsoft.Windows.CommonLanguageRuntime" version="4.0.30319.0" />
        </dependentAssembly>
      </dependency>
    
  4. 針對必須在全域組件快取中預先安裝之組件的必要條件,為指定必要組件的 dependentAssembly 元素設定 supportUrl

      <dependency>
        <dependentAssembly dependencyType="preRequisite" allowDelayedBinding="true" supportUrl=" http://www.adatum.com/MyApplication/missingSampleGACAssembly.htm">
          <assemblyIdentity name="SampleGACAssembly" version="5.0.0.0" publicKeyToken="04529dfb5da245c5" processorArchitecture="msil" language="neutral" />
        </dependentAssembly>
      </dependency>
    
  5. 選擇性。 針對以 .NET Framework 4 為目標的應用程式,請在文字編輯器中開啟 ClickOnce 應用程式的部署資訊清單 (.application 檔案)。

  6. 針對 .NET Framework 4 必要條件,請將 supportUrl 屬性新增至 compatibleFrameworks 元素中:

    <compatibleFrameworks  xmlns="urn:schemas-microsoft-com:clickonce.v2" supportUrl="http://adatum.com/MyApplication/CompatibleFrameworks.htm">
      <framework targetVersion="4.0" profile="Client" supportedRuntime="4.0.30319" />
      <framework targetVersion="4.0" profile="Full" supportedRuntime="4.0.30319" />
    </compatibleFrameworks>
    
  7. 手動變更應用程式資訊清單之後,您也必須使用數位憑證來重新簽署應用程式資訊清單,然後更新並重新簽署部署資訊清單。 使用 Mage.exeMageUI.exe SDK 工具來完成這項工作,因為使用 Visual Studio 重新產生這些檔案會清除您的手動變更。 如需有關如何使用 Mage.exe 來重新簽署資訊清單的詳細資訊,請參閱 < 如何:重新簽署應用程式和部署資訊清單

.NET Framework 安全性

如果應用程式標示為在部分信任中執行,則不會在對話方塊中顯示支援 URL。