Share via


ServerDocument.Close, méthode

Ferme l'objet ServerDocument.

Espace de noms :  Microsoft.VisualStudio.Tools.Applications
Assembly :  Microsoft.VisualStudio.Tools.Applications.ServerDocument (dans Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll)

Syntaxe

'Déclaration
Public Sub Close
public void Close()

Notes

Appelez cette méthode pour libérer toutes les ressources et fermer ServerDocument.

Exemples

L'exemple de code suivant crée un ServerDocument, affiche l'URL du manifeste de déploiement, puis utilise la méthode Close pour fermer le ServerDocument.

Cet exemple nécessite :

  • Projet d'application console ou un autre projet non-Office.

  • Références aux assemblys suivants :

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll et Microsoft.VisualStudio.Tools.Applications.Runtime.dll (si le projet cible .NET Framework 4 ou .NET Framework 4.5).

      ou

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll et Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll (si le projet cible le .NET Framework 3.5).

  • Instructions Imports (pour Visual Basic) ou using pour C#) pour les espaces de noms Microsoft.VisualStudio.Tools.Applications et Microsoft.VisualStudio.Tools.Applications.Runtime au haut de votre fichier de code.

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

Sécurité .NET Framework

Voir aussi

Référence

ServerDocument Classe

Microsoft.VisualStudio.Tools.Applications, espace de noms