Attaching a Solution to a Document Using Custom Document Properties

There is another way to attach a VSTO solution to your document without programming. You might use this technique when you have an existing VSTO solution that is pointing to a deployment manifest on a particular server. If the server goes down and you need to load the assembly from a different server, you can easily change the custom document properties to reference the new location.

There are two custom document properties: _AssemblyName and _AssemblyLocation. In this section, you will modify the custom document properties of a Word or Excel document.

1. Open the Word or Excel document.

2. On the File menu, click Properties, and then click the Custom tab to open the Custom Properties dialog box.

3. Set the _AssemblyLocation to the path of the deployment manifest file. This can be a file, a UNC, or an HTTP path. As in Listing 13.2, you can set the property to C:\Invoice\Invoice.application. If this is not a VSTO document, you must first create this property.

4. Set _AssemblyName to an asterisk (*). If this is a VSTO document, you must first create this property.

5. Click OK to close the Properties dialog box.

6. Save the document.

When the document is opened after the custom properties have been set, the VSTO runtime attaches the solution to the document. The runtime embeds the Runtime Storage Control, embeds the application manifest, and loads the assembly.

0 0

Post a comment