I've just got a couple of lessons from the last week to share around developing Office 2003 (and specifically Visio 2003) Add-Ins
I'm also trying to saturate this post with links because I have come up with a good size folder in my bookmarks for what started out to be a simple task.
- Grab the PIA's. Anyone who wants to run the Add-In will need them. Alternatively they can be installed from the Office Add/Remove/Repair under the guise of .NET Programmability Support, but in reality the user may not have the media or security access to do this. Do NOT however ship the PIA's in your bits. Ship the PIA's with your bits: This means 2x MSI's.
- Using NAant to automate the build with csc.exe & vbc.exe is suboptimal. I'm keeping my project to one small assembly that depends on the PIAs, and also depends on another assembly that does the heavy lifting but has no ref to the PIA's.
- Strong Name everything. Well, strong name everything anyway, but when trying to pass of managed code as COM it is essential.
- You cannot load a .NET DLL, even one with the ComVisibleAttribute on the Assembly or Classes, via the Office UI. You just can't. KB316723 gives an explanation. This is because Office will try and register it the old regsvr32 way, which of course won't work. To get a .NET DLL into the Macros -> Add-Ins list, you must write the registry entry under: HKEY_CURRENT_USER\Software\Microsoft\<office program name>\Addins\
- This brings me to my next point. KB316723 hints at it, but your setup must write a HKCU key not a HKLM key. The Shared Add-In Wizard in Studio is ambiguous when it shows you this choice:

- I know this may be contentious, but consider using VB.NET over C#. This depends of course, but some parts of the Office object model make heavy use of Optional Parameters which C# does not support. It has been noted elsewhere what Type.Missing can do for readability. Having said that, it does vary greatly depending on where in the Office Object Model you are.
- Spend some time with the Setup project that the Shared Add-In Wizard makes and test it. Once you like it, reverse engineer it to a WiX script and feed that to your automated build. For the record, you do that with:
Dark.exe –x path Debug/msi My.wxs
Candle My.wxs
Light My.Wixobj
- To extra points when dealing with WiX-ified MSI's
- It's useful to note that the extracted (-x) resources take many forms. DefBannerBitmap.ibd for example is just a bitmap. I think it is easier to rename it to .bmp & tweak it in Photoshop than to add a new banner in Visual Studio.
- The Add-in reg setting mentioned in point #4 above references an assembly version. Visual Studio tweeks this for you but your WiX script will be frozen at the time your Dark.exe'd it. So don't auto-increment your assembly version numbers, or tweak you WiX script. The choice is yours but your MSI must write the version of the Add-In DLL to the target machine's registry.
Listening To: Leftfield, Leftism