Provides access to the cached data and customization information in a document or workbook that is part of a document-level customization created by using the Office development tools in Visual Studio.
Assembly: Microsoft.VisualStudio.Tools.Applications.ServerDocument (in Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll)
Thetype exposes the following members.
|ServerDocument(String)||Initializes a new instance of the class using the full path of the document to be loaded.|
|ServerDocument(Byte(), String)||Initializes a new instance of the class using a byte array that represents the document to be loaded and the file name extension of the document.|
|ServerDocument(Stream, String)||Initializes a new instance of the class using a stream that represents the document to be loaded and the file name extension of the document.|
|ServerDocument(String, FileAccess)||Initializes a new instance of the class using the full path of the document to be loaded and a value that indicates the file access for the document.|
|CachedData||Gets a CachedData object that represents the cached data that is contained in the document.|
|DeploymentManifestUrl||Gets or sets the URL of the deployment manifest for the customization that is associated with the document.|
|Document||Gets the byte array of an in-memory document that is loaded into the .|
|SolutionId||Gets a GUID that the Visual Studio Tools for Office runtime uses to identify the solution.|
|AddCustomization(String, Uri)||Attaches a customization to the specified document by using the specified assembly name and deployment manifest.|
|AddCustomization(String, String, Guid, Uri)||Attaches a customization to the specified document by using the specified document, assembly name, solution ID, and deployment manifest.|
|AddCustomization(String, String, Guid, Uri, Boolean, String())||Infrastructure.|
|Close||Closes the object.|
|Equals||Determines whether the specified object is equal to the current object. (Inherited from Object.)|
|GetCustomizationVersion||Returns the version of the Visual Studio Tools for Office runtime that was used to create the customization that is associated with the specified document.|
|GetHashCode||Serves as the default hash function. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|IsCacheEnabled||Gets a value that indicates whether the specified document has a data cache.|
|IsCustomized||Gets a value that indicates whether the specified document has a customization that was created by using the Visual Studio 2010 Tools for Office Runtime.|
|RemoveCustomization||Removes the customization from the document.|
|Save||Saves any changes that were made to the document by using the class.|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
Use the class to manage certain aspects of document-level customizations on a computer that does not have Excel or Word installed. You typically use this class in applications that do not integrate with Office, such as Console projects or Windows Forms projects, rather than Office projects.
Use the following members of the class to perform common tasks:
To access and modify data in the data cache of a document on a server, use the CachedData property.
To access or change the URL of the deployment manifest that is associated with the document, use the DeploymentManifestUrl property.
There are two different versions of the class in the Visual Studio 2010 Tools for Office Runtime. The version you should use depends on the target .NET Framework of the application in which you want to use the class:
For applications that target the .NET Framework 4 or the .NET Framework 4.5, use the class in the Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll assembly.
For applications that target the .NET Framework 3.5, use the Microsoft.VisualStudio.Tools.Applications.ServerDocument class in the Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll assembly.
For more information, see Managing Documents on a Server by Using the ServerDocument Class.
Choosing Which Constructor to Use
To use the class to access the cached data or the deployment manifest URL in a document, you must create a object.
There are two sets of constructors:
A set that you can use to access a document that has already been opened in memory.
A set that you can use to access a document that is on disk.
To access a document that has already been opened in memory, use one of the following constructors:
These constructors accept a byte array or a Stream that represents the document in memory. This is useful if you want to modify the cached data or application manifest in the document before streaming it to a destination by using the HTTP protocol. To use these constructors, the document must already have a customization; otherwise, these constructors will throw a CannotLoadManifestException exception.
To access a document that is on disk, use one of the following constructors:
These constructors accept the full path of the document that you want to open. By default, the document is opened with read/write access. If you want to open the document with read-only or write-only access, use the constructor that has a FileAccess parameter.
The following code example creates a new that loads a specified document and then displays the URL of the deployment manifest for the customization that is attached to the document.
This example requires:
A console application project or some other non-Office project.
References to the following assemblies:
Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll and Microsoft.VisualStudio.Tools.Applications.Runtime.dll (if the project targets the .NET Framework 4 or the .NET Framework 4.5).
Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll and Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll (if the project targets the .NET Framework 3.5).
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