Click to Rate and Give Feedback
MSDN
MSDN Library

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
 Collapse AllExpand All        Code: All Code: Multiple Code: Visual Basic Code: C# Code: Visual C++ Code: J# Code: JScript 
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)

Visual Basic (Declaration)
Public Shared Function AddCustomization ( _
    documentPath As String, _
    assemblyName As String, _
    deploymentManifestPath As String, _
    applicationVersion As String, _
    makePathsRelative As Boolean _
) As String
Visual Basic (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)
C#
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.

ExceptionCondition
ArgumentNullException

The documentPath, assemblyName, or applicationVersion parameter is nullNothingnullptra 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.

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.

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.

Visual Basic
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

C#
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.");
    }
}

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker