Visio in Visual Studio Tools for Office – Public Preview Availability


I mentioned earlier the release of VSTO for Visio Beta 1 users. Now that Beta 2 is available, I’m happy to announce that anyone can try this out. To download the CTP of VSTO “v3”, go here. Note that you need to install Visual Studio first, then Visio 2007 Beta 2, and finally VSTO.

The main Visio-related functionality that you get when you use VSTO are the wizards for creating C# and VB.Net add-in projects. Although the basic idea is similar to the wizards that ship with the Visio SDK, there are a couple key advantages to using the ones in VSTO:

  • The programming model is somewhat simpler in that the full COM interop interface (IDTExtensibility2) is hidden. You basically just get a Visio application object, a Startup event, and a Shutdown event to work with. This makes the add-in a lot cleaner and easier to manage.
  • They automatically handle the creation of the COM shims (read this article if you don’t know what that means). This means, among other things, that it is a lot simpler to sign your add-in and if your add-in goes down it doesn't bring down all of the other add-ins.

In playing around with this, one thing that I have noticed is that by default objects you create are not COMVisible (whereas they are in add-ins created using the Visio SDK wizards). This means that you need to set this explicitly for any objects that you need to be COMVisible. I first saw this when creating and working with Event Sinks - if you see COM exception 0x86DB0898 when you do an AddAdvise this is your issue. To fix it, add the following lines above the relevant object:

  • For VB.Net: <ComVisibleAttribute(True)>
  • For C#: [ComVisible(true)]