Share via


ServerDocument.DeploymentManifestUrl 屬性

取得或設定與文件相關聯之自訂的部署資訊清單 URL。

命名空間:  Microsoft.VisualStudio.Tools.Applications
組件:  Microsoft.VisualStudio.Tools.Applications.ServerDocument (在 Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll 中)

語法

'宣告
Public Property DeploymentManifestUrl As Uri
    Get
    Set
public Uri DeploymentManifestUrl { get; set; }

屬性值

型別:System.Uri
URL,指定與文件關聯之自訂的部署資訊清單名稱和位置。

備註

如果您將自訂的部署資訊清單移至不同的位置,而且要文件從新位置尋找自訂更新,請將這個屬性設定為新的 URL。 如果設定這個屬性,URL 必須指向已經與文件關聯之自訂的部署資訊清單。

您無法使用這個屬性將新自訂與文件產生關聯。 若要將自訂加入至未自訂的文件,請使用 AddCustomization 方法。 若要將不同的自訂加入至已自訂的文件,請先使用 RemoveCustomization 方法移除目前的自訂,再使用 AddCustomization 方法。

取得以 .NET Framework 3.5 為目標之應用程式中的 URL

當您在以 .NET Framework 3.5 為目標的應用程式內的 Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll 組件中使用 ServerDocument 類別時,DeploymentManifestUrl 屬性只有在文件層級自訂已安裝在您執行應用程式的電腦上時才會傳回目前的部署資訊清單 URL。 否則,這個函式會傳回 nullNull 參照 (即 Visual Basic 中的 Nothing)。

如果您需要取得文件層級自訂的部署資訊清單 URL,且此自訂不是安裝於您執行應用程式的電腦 (如在發佈文件層級自訂的伺服器上),請在應用程式中以 .NET Framework 4 為目標,參考 Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll 組譯碼,並且在該組譯碼中使用 ServerDocument類別。

範例

在下列程式碼範例中,會使用 ServerDocument(String) 建構函式建立新的 ServerDocument 物件,以載入指定的文件。 範例接著會顯示附加至文件之自訂的部署資訊清單 URL。

這個範例需要:

  • 主控台應用程式專案或其他非 Office 專案。

  • 下列組件的參考:

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll 和 Microsoft.VisualStudio.Tools.Applications.Runtime.dll (如果專案的目標是 .NET Framework 4)。

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll 和 Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll (如果專案的目標是 .NET Framework 3.5)。

  • Microsoft.VisualStudio.Tools.ApplicationsMicrosoft.VisualStudio.Tools.Applications.Runtime 命名空間 (在程式碼檔最頂端) 的Imports (Visual Basic) 或 using (C#) 陳述式。

Private Sub CreateServerDocumentFromPath(ByVal documentPath As String)
    Dim runtimeVersion As Integer = 0
    Dim serverDocument1 As ServerDocument = Nothing

    Try
        runtimeVersion = ServerDocument.GetCustomizationVersion(documentPath)
        If runtimeVersion = 3 Then
            serverDocument1 = New ServerDocument(documentPath)
            MessageBox.Show("The URL of the deployment manifest is: " & vbLf & _
                serverDocument1.DeploymentManifestUrl.ToString())
        End If

    Catch ex As System.IO.FileNotFoundException
        System.Windows.Forms.MessageBox.Show("The specified document does not exist.")
    Catch ex As UnknownCustomizationFileException
        System.Windows.Forms.MessageBox.Show("The specified document has a file " & _
            "extension that is not supported by Visual Studio Tools for Office.")
    Finally
        If Not (serverDocument1 Is Nothing) Then
            serverDocument1.Close()
        End If
    End Try
End Sub
private void CreateServerDocumentFromPath(string documentPath)
{
    int runtimeVersion = 0;
    ServerDocument serverDocument1 = null;

    try
    {
        runtimeVersion = ServerDocument.GetCustomizationVersion(documentPath);
        if (runtimeVersion == 3)
        {
            serverDocument1 = new ServerDocument(documentPath);
            MessageBox.Show("The URL of the deployment manifest is: \n" +
                serverDocument1.DeploymentManifestUrl.ToString());
        }
    }
    catch (System.IO.FileNotFoundException)
    {
        System.Windows.Forms.MessageBox.Show("The specified document does not exist.");
    }
    catch (UnknownCustomizationFileException)
    {
        System.Windows.Forms.MessageBox.Show("The specified document has a file " +
            "extension that is not supported by Visual Studio Tools for Office.");
    }
    finally
    {
        if (serverDocument1 != null)
            serverDocument1.Close();
    }
}

.NET Framework 安全性

請參閱

參考

ServerDocument 類別

Microsoft.VisualStudio.Tools.Applications 命名空間