Compartilhar via


Método ServerDocument.Close

Fecha o objeto de ServerDocument .

Namespace:  Microsoft.VisualStudio.Tools.Applications
Assembly:  Microsoft.VisualStudio.Tools.Applications.ServerDocument (em Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll)

Sintaxe

'Declaração
Public Sub Close
public void Close()

Comentários

Chamar este método para liberar quaisquer recursos e feche ServerDocument.

Exemplos

O exemplo de código a seguir cria um novo ServerDocument, exibe o URL de manifesto de implantação, e usa o método de Close para fechar ServerDocument.

Este exemplo requer:

  • Um projeto de aplicativo do console ou qualquer outro projeto do Office não.

  • Referências para os seguintes conjuntos:

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll e Microsoft.VisualStudio.Tools.Applications.Runtime.dll (se o projeto utiliza .NET Framework 4 ou .NET Framework 4.5).

      ou

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll e Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll (se o projeto utiliza o .NET Framework 3.5).

  • Imports (Visual Basic) ou instruções de using (para C#) para Microsoft.VisualStudio.Tools.Applications e namespaces de Microsoft.VisualStudio.Tools.Applications.Runtime na parte superior do arquivo de código.

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();
    }
}

Segurança do .NET Framework

Consulte também

Referência

ServerDocument Classe

Namespace Microsoft.VisualStudio.Tools.Applications