ServerDocument.Close-Methode
Schließt das ServerDocument-Objekt.
Namespace: Microsoft.VisualStudio.Tools.Applications
Assembly: Microsoft.VisualStudio.Tools.Applications.ServerDocument (in Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll)
Syntax
'Declaration
Public Sub Close
public void Close()
Hinweise
Rufen Sie diese Methode auf, um alle Ressourcen freizugeben und das ServerDocument zu schließen.
Beispiele
Im folgenden Codebeispiel wird ein neues ServerDocument erstellt, die URL des Bereitstellungsmanifests angezeigt und dann die Close-Methode verwendet, um das ServerDocument zu schließen.
Dieses Beispiel setzt Folgendes voraus:
Ein Konsolenanwendungsprojekt oder ein anderes Nicht-Office-Projekt.
Verweise auf die folgenden Assemblys:
Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll und Microsoft.VisualStudio.Tools.Applications.Runtime.dll (wenn das Projekt .NET Framework 4 oder .NET Framework 4.5 als Ziel hat).
oder
Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll und Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll (wenn das Projekt auf .NET Framework 3.5 abzielt).
Imports-Anweisungen (für Visual Basic) oder using-Anweisungen (für C#) für Microsoft.VisualStudio.Tools.Applications- und Microsoft.VisualStudio.Tools.Applications.Runtime-Namespaces am Anfang der Codedatei.
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-Sicherheit
- Volle Vertrauenswürdigkeit für den unmittelbaren Aufrufer. Dieser Member kann von nur teilweise vertrauenswürdigem Code nicht verwendet werden. Weitere Informationen finden Sie unter Verwenden von Bibliotheken aus teilweise vertrauenswürdigem Code.