The ServerDocument class has two main purposes:
To access the cached data or the application manifest in a document, you must first create a ServerDocument object by passing the document to one of the ServerDocument constructors. You can then access the cached data by using the CachedData property, and you can access the application manifest by using the AppManifest property. The application manifest provides information about the customization assemblies that are attached to the document. For more information, see Application and Deployment Manifests in Office Solutions.
To add or remove a customization, use the static AddCustomization and RemoveCustomization methods. These methods are useful if you want to add or remove a customization when the document is not on the development computer. You can call these methods only when the computer has Word or Excel installed, because these methods start Word and Excel to add or remove the customization.
Choosing Which Constructor to Use
There are two sets of ServerDocument constructors:
Accessing a Document in Memory
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 Visual Studio Tools for Office customization; otherwise, these constructors will throw a CannotLoadManifestException exception.
Accessing a Document on Disk
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. The document must already have a Visual Studio Tools for Office customization.
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.
If you want to open a document that does not yet have a Visual Studio Tools for Office customization, use a constructor that has the Boolean onClient parameter. If you set this parameter to true, the Visual Studio Tools for Office runtime will create an empty Runtime Storage Control in the document. This is useful if you want to add cached data to a document that does not yet have a customization. The client computer must have Word or Excel installed before you can call the ServerDocument constructor, because the Visual Studio Tools for Office runtime starts Word or Excel to create the Runtime Storage Control. For more information about the Runtime Storage Control, see Runtime Storage Control Overview.