Dev Luv: Visio and .NET Development


Visio, like the other apps in Office, is a COM application. Ergo, it has COM interfaces and needs a Primary Interop Assembly (PIA) to work with .NET applications. A pretty decent percentage of our current dev community uses .NET to build custom Visio apps. 

 

I’ve got a two-year old son who takes soccer for toddlers and several times a “practice” (mostly games of red-light-green-light and kicking the ball in the goal), the coach asks the kids, “What’s the number one rule in a soccer?” Whereupon all the kids chorus, “No hands!” (It’s very cute.) The equivalent of “No hands!” for Visio .NET programming is “No unnecessary objects!” This is the single most important thing for .NET developers to remember when doing Visio custom applications. To help with this, Visio automation provides several methods that let you work with more than one object at a time (SetFormulas, DropMany, etc. that I talked about in an earlier blog). Using these methods provides two benefits – it’s faster and you’re not managing as many live objects at a single time. It’s especially important for .NET programming because you want to minimize how many times you actually have to use the PIA layer. Visio is no better or no worse than other Office applications in PIA overhead on performance. As a .NET programmer, you can minimize that overhead as much as possible in the app by minimizing the amount of objects you have to create to do whatever your app does.

 

When you’re deploying your .NET application, there’s another thing to consider when deploying your app. The Visio setup application for Visio 2003 Professional and Visio 2003 Standard will install the PIAs for all of our typelibs (Visio typelib, ActiveX Control typelib, and SaveAsWeb typelib) no matter what install option you choose, whether it’s Minimal, Typical, or Custom – provided that the CLR 1.1 is installed on the client machine. If the CLR 1.1 is NOT installed on the client machine, the Visio setup application will not install the required PIAs and poof, your app will fall flat on its face when the user tries to run it. Once you install the CLR 1.1 on the client machine, you can use the Visio setup application to “repair” your installation and put the PIAs on it, or go into Add/Remove options in the setup application and select the .NET Programmability Support option. Both of those options are after the fact of your application failing, though, so I would make sure that if you are deploying your .NET application on a client that has Visio already installed, you should check first for the presence of the CLR 1.1. If it's there, you're good. If it's not, you should install the CLR 1.1 and then programmatically trigger a repair of the Visio appplication. The MSIexec docs describe how you can script an application repair.

 

-- Mai-lan

 

This posting is provided "AS IS" with no warranties, and confers no rights.

 

Skip to main content