Bagikan melalui


How to: Change the Path to the Deployment Manifest Programmatically (2003 System)

Applies to

The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office.

Project type

  • Document-level projects

Microsoft Office version

  • Microsoft Office 2003

For more information, see Features Available by Application and Project Type.

You can use the object model in the Visual Studio Tools for Office runtime to programmatically update the application manifest that is embedded in a document that is part of a document-level customization.

You must put the code for manipulating the object model in a new project (not your Visual Studio Tools for Office solution), such as a console application or ASP.NET page. Visual Studio Tools for Office includes a sample that demonstrates how to create a tool that can be used to edit the embedded application manifest. For more information, see ServerDocument Sample.

There is another model for updating manifests that involves modifying XML files that are generated by the Publish Wizard. For more information, see How to: Change the Location of Document-Level Customizations (2003 System).

Note

This topic does not apply to application-level add-ins, because they do not use embedded application manifests. To change the path to the deployment manifest of an add-in, use a text editor to update the application manifest that is on the client computer. For more information, see Application Manifests for Office Solutions (2003 System). For more information about application-level add-ins and document-level customizations, see Architecture of Document-Level Customizations.

To change the path to the deployment manifest programmatically

  1. Create a new project to change the manifest file in the Office document. This project can be of any type—for example, a command line solution.

  2. Add a reference to Microsoft.VisualStudio.Tools.Applications.Runtime to this project.

  3. Add an Imports or using statement for the runtime to the top of your code file.

    Imports Microsoft.VisualStudio.Tools.Applications.Runtime
    
    using Microsoft.VisualStudio.Tools.Applications.Runtime;
    
  4. Create an instance of ServerDocument, and pass in the solution document. Assign the new deployment manifest path to the DeployManifestPath property.

    Dim sd As ServerDocument = Nothing 
    Try
        sd = New ServerDocument("C:\Documents\SolutionDocument.doc")
        sd.AppManifest.DeployManifestPath = _
            "\\NewServer\ShareFolder\SolutionDocument.application"
    
    ServerDocument sd = null;
    try
    {
        sd = new ServerDocument(@"C:\Documents\SolutionDocument.doc");
        sd.AppManifest.DeployManifestPath = 
            @"\\NewServer\ShareFolder\SolutionDocument.application";
    
  5. Save your changes and close the document.

        sd.Save()
    
    Finally 
        If Not sd Is Nothing Then
            sd.Close()
        End If 
    End Try
    
        sd.Save();
    }
    finally
    {
        if (sd != null)
        {
            sd.Close();
        }
    }
    

See Also

Tasks

How to: Update Application Manifest Assembly Paths Programmatically (2003 System)

How to: Attach Managed Code Extensions to Documents (2003 System)

How to: Remove Managed Code Extensions from Documents (2003 System)

Concepts

Application and Deployment Manifests in Office Solutions

Deploying Office Solutions (2003 System)

Reference

Application Manifests for Office Solutions (2003 System)

Deployment Manifests for Office Solutions (2003 System)