ServerDocument.Close – metoda
Zavře ServerDocument objektu.
Obor názvů: Microsoft.VisualStudio.Tools.Applications
Sestavení: Microsoft.VisualStudio.Tools.Applications.ServerDocument (v Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll)
Syntaxe
'Deklarace
Public Sub Close
public void Close()
Poznámky
Volání této metody k uvolnění všech prostředků a zavření ServerDocument.
Příklady
Následující příklad kódu vytvoří nový ServerDocument, zobrazí adresu URL manifestu nasazení a potom použije Close metoda zavřete ServerDocument.
Tento příklad vyžaduje:
Projekt aplikace konzoly nebo jiného projektu mimo sadu Office.
Odkazy na následující sestavení:
Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll a Microsoft.VisualStudio.Tools.Applications.Runtime.dll (Pokud projekt cílen .NET Framework 4 nebo .NET Framework 4.5).
nebo
Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll a Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll (Pokud je projekt cílen na rozhraní.NET Framework 3.5).
Imports(pro Visual Basic) nebo using (pro jazyk C#) příkazy pro Microsoft.VisualStudio.Tools.Applications a Microsoft.VisualStudio.Tools.Applications.Runtime obory názvů v horní části souboru kódu.
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();
}
}
Zabezpečení rozhraní .NET Framework
- Plná důvěra přímému volajícímu. Částečně zabezpečený kód nemůže tento člen použít. Další informace naleznete v tématu Používání knihoven z částečně důvěryhodného kódu.