Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
 How to: Update Application Manifest...

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

Other versions are also available for the following:
Visual Studio Tools for the Microsoft Office System
How to: Update Application Manifest Assembly Paths Programmatically

Note Required applications

The features in this topic are available only if you have the required applications installed.

For more information, see Features Available by Product Combination.

  • One of these development environments:

    VSTO 2005

    -or-

    Visual Studio Team System

  • Microsoft Office 2003

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 for Microsoft Office Word 2003 or Microsoft Office Excel 2003. Generally this is not necessary, because there is another model for updating manifests that involves modifying XML files on a server. For more information, see How to: Change the Location of Document-Level Customizations.

When you change the paths to the assemblies, you must create a new application manifest and replace the one that has the outdated paths. You can use environment variables, such as %ProgramFiles% or %UserProfile%, in the paths to the assemblies.

You must put the code for manipulating the object model in a new project (not your Visual Studio Tools for Office solution), for example in a console application or Windows Forms project. 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 Application Manifest Editor Sample.

NoteNote

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

To change the path to the assemblies programmatically

  1. Add a reference to Microsoft.VisualStudio.Tools.Applications.Runtime to your object model manipulation project if you do not already have one.

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

    Visual Basic
    Imports Microsoft.VisualStudio.Tools.Applications.Runtime
    
    C#
    using Microsoft.VisualStudio.Tools.Applications.Runtime;
    
  3. Call the static AddCustomization method of the ServerDocument class, and pass in the required arguments. You must first call the RemoveCustomization method to remove any existing Visual Studio Tools for Office customizations from the document, or AddCustomization will throw an InvalidOperationException.

    Visual Basic
    Dim solutionDocument As String = "C:\Documents\ExcelApplication.xls"
    Dim assemblyName As String = "ExcelApplication.dll"
    Dim manifestPath As String = "\\serversame\deployshare\ExcelApplication.application"
    Dim applicationVersion As String = "1.0.0.1"
    
    If ServerDocument.IsCustomized(solutionDocument) Then
        ServerDocument.RemoveCustomization(solutionDocument)
    End If
    
    ServerDocument.AddCustomization( _
        solutionDocument, assemblyName, manifestPath, _
        applicationVersion, False)
    
    C#
    string solutionDocument = @"C:\Documents\ExcelApplication.xls";
    string assemblyName = "ExcelApplication.dll";
    string manifestPath = @"\\servername\deployshare\ExcelApplication.application";
    string applicationVersion = "1.0.0.1";
    
    if (ServerDocument.IsCustomized(solutionDocument))
    {
        ServerDocument.RemoveCustomization(solutionDocument);
    }
    
    ServerDocument.AddCustomization(
        solutionDocument, assemblyName, manifestPath, 
        applicationVersion, false);
    

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker