Saturday, February 27, 2010

Reg-Free COM in VSTO Applications, Part 2

A simple test did have us using the Activation Context API to load a COM object in Word, however we never could get it working with a more advanced solution, such as ActiveX controls. The results of the basic test show that this should be possible, but for now this is on the back-burner. Someone with a very advanced knowledge of manifests and SxS should be able to get this set up.

From a high-level view, there are two things you need to do:
  1. P/Invoke the Activation Context API, and use it to load the manifest that your reg-free COM information is in (usually it's Native.[assemblyname].manifest) during the startup of your VSTO add-in.
  2. The VSTO build process will not include your Native.[assemblyname].manifest in the Application Manifest, so you'll have to add it yourself. Since I wrote it at work I can't share our method, but we ended up creating a command-line tool that runs as a post-build step and manually adds the file reference using XmlDocument, and re-hashes and re-signs everything.

No comments:

Post a Comment