Share via


ServerDocument.AddCustomization Method (String, String, String, String, Boolean) (2003 System)

Adds a new application manifest to the specified document.

Namespace:  Microsoft.VisualStudio.Tools.Applications.Runtime
Assembly:  Microsoft.VisualStudio.Tools.Applications.Runtime (in Microsoft.VisualStudio.Tools.Applications.Runtime.dll)

Syntax

'Declaration
Public Shared Function AddCustomization ( _
    documentPath As String, _
    assemblyName As String, _
    deploymentManifestPath As String, _
    applicationVersion As String, _
    makePathsRelative As Boolean _
) As String
'Usage
Dim documentPath As String
Dim assemblyName As String
Dim deploymentManifestPath As String
Dim applicationVersion As String
Dim makePathsRelative As Boolean
Dim returnValue As String

returnValue = ServerDocument.AddCustomization(documentPath, _
    assemblyName, deploymentManifestPath, _
    applicationVersion, makePathsRelative)
public static string AddCustomization(
    string documentPath,
    string assemblyName,
    string deploymentManifestPath,
    string applicationVersion,
    bool makePathsRelative
)

Parameters

  • documentPath
    Type: System.String
    The path of the document that you want to customize.
  • assemblyName
    Type: System.String
    The path of the solution assembly to attach to the document.
  • deploymentManifestPath
    Type: System.String
    The URL of the deployment manifest for the solution.
  • applicationVersion
    Type: System.String
    The version of the application manifest, specifying the major version, minor version, build number, and revision number separated by periods (.).
  • makePathsRelative
    Type: System.Boolean
    true to make all the paths in the application manifest relative to the document location; false to make all the paths absolute.

Return Value

Type: System.String
An XML string that contains the contents of the new application manifest.

Exceptions

Exception Condition
ArgumentNullException

The documentPath, assemblyName, or applicationVersion parameter is nulla null reference (Nothing in Visual Basic) or empty.

FileNotFoundException

The documentPath or assemblyName parameter refers to a file that does not exist.

InvalidOperationException

The document specified by documentPath already has a Visual Studio Tools for Office customization.

ArgumentException

The applicationVersion parameter does not have the valid format.

COMException

The document specified by documentPath does not have a Runtime Storage Control, and the document is on a computer that does not have the appropriate Microsoft Office application for the document installed.

Remarks

The AddCustomization(String, String, String, String, Boolean) method adds entries to the application manifest that indicate the specified solution assembly, the deployment manifest, and the version of the application manifest. For more information on application and deployment manifests, see Application and Deployment Manifests in Office Solutions.

This method adds a Runtime Storage Control to the document, if the document does not have one. This process requires that the document be on a computer that has Microsoft Office Word (for Word documents) or Microsoft Office Excel (for Excel workbooks) installed. For more information on the Runtime Storage Control, see Runtime Storage Control Overview.

If the specified document does not contain a control that the solution assembly expects the document to have, the AddCustomization(String, String, String, String, Boolean) method will succeed, but the assembly will fail to load when the user opens the document.

The applicationVersion parameter must be a string that specifies the major version, minor version, build number, and revision number separated by periods (.). For example, 1.0.0 is invalid, but 1.0.0.1 is valid.

Examples

The following code example uses the AddCustomization(String, String, String, String, Boolean) method to add a new application manifest to the specified document, using the specified assembly and deployment manifest. This example requires a reference to the Microsoft.VisualStudio.Tools.Applications.Runtime assembly, and an Imports (for Visual Basic) or using (for C#) statement for the Microsoft.VisualStudio.Tools.Applications.Runtime namespace at the top of your code file.

Private Sub AddNewCustomization(ByVal fileName As String)
    If Not ServerDocument.IsCustomized(fileName) Then
        Dim assemblyName As String = "ExcelApplication1.dll"
        Dim deploymentManifestPath As String = _
            "\\servername\deployshare\ExcelApplication1.application"
        Dim applicationVersion As String = "1.0.0.1"
        Dim newManifest As String = ServerDocument.AddCustomization( _
            fileName, assemblyName, deploymentManifestPath, _
            applicationVersion, False)
        MsgBox("The document has been customized.")
    Else
        MsgBox("The specified document is already " + _
            "customized.")
    End If
End Sub
private void AddNewCustomization(string fileName)
{
    if (!ServerDocument.IsCustomized(fileName))
    {
        string assemblyName = "ExcelApplication1.dll";
        string deploymentManifestPath =
            @"\\servername\deployshare\ExcelApplication1.application";
        string applicationVersion = "1.0.0.1";

        string newManifest = ServerDocument.AddCustomization(
            fileName, assemblyName, deploymentManifestPath, 
            applicationVersion, false);

        MessageBox.Show("The document has been customized.");
    }
    else
    {
        MessageBox.Show("The specified document is already " +
            "customized.");
    }
}

Permissions

See Also

Reference

ServerDocument Class

ServerDocument Members

AddCustomization Overload

Microsoft.VisualStudio.Tools.Applications.Runtime Namespace

Other Resources

Runtime Storage Control Overview

Application and Deployment Manifests in Office Solutions