
Editing the Embedded Application Manifest
When you build your solution, the document assumes that the assembly is in the same folder as the document. The location of the assembly is stored in an application manifest that is embedded in the document. If you deploy the document and assembly to different folders, you must edit the embedded application manifest to specify the new assembly path. In the following steps, you will use the ServerDocument class to edit the embedded application manifest in the document to point to the new location of the customization assembly. The code that uses ServerDocument to edit the embedded application manifest must be outside of the Visual Studio Tools for Office project assembly that is associated with document you are deploying.
To edit the embedded application manifest
-
Create a new Console Application project. For more information, see How to: Create Solutions and Projects.
-
Add a reference to the Microsoft.VisualStudio.Tools.Applications.Runtime.dll assembly to the new project.
-
Add the following using statement (C#) or Imports statement (Visual Basic) to the top of the Program.cs or Module1.vb code file.
Imports Microsoft.VisualStudio.Tools.Applications.Runtime
using Microsoft.VisualStudio.Tools.Applications.Runtime;
-
Add the following code in the Main method to update the embedded application manifest. Replace <full document path> with the full path of the document in its build location on the development computer—for example, <project folder>\bin\debug\WordDeployment.doc. Replace <full assembly path> with the full path of the assembly in the network folder it will be deployed to—for example, \\DeploymentServer\DeploymentFolder\WordDeployment.dll.
Dim sd As ServerDocument = Nothing
Try
sd = New ServerDocument("<full document path>")
sd.AppManifest.Dependency.AssemblyPath = _
"<full assembly path>"
sd.Save()
Finally
If Not sd Is Nothing Then
sd.Close()
End If
End Try
ServerDocument sd = null;
try
{
sd = new ServerDocument(@"<full document path>");
sd.AppManifest.Dependency.AssemblyPath =
@"<full assembly path>";
sd.Save();
}
finally
{
if (sd != null)
{
sd.Close();
}
}
-
Build and run the project. The console application updates the assembly path in the embedded application manifest and then closes.
Note |
|---|
| Make sure that the document is not open in an instance of Word or the project designer. If the document is open, the attempt to access the document using ServerDocument will fail. |
-
Close the Console Application project.