Crash Course in VSTO

I’ve inherited yet another project at work. This latest one includes a series of reports all done in Excel with VBA macros. The code for these macros is almost unmaintainable, so I’m trying get these rewritten using Visual Studio Tools for Office (VSTO). This is my first experience with VSTO and right now I’m in the “proof of concept” stage, struggling with deploying a test case using ClickOnce.

So far, here’s what I’ve learned:

  • Visual Studio 2008 ships with VSTO “in the box”
  • There are several options, depending on if you want to target Office 2003, 2007, .NET 2.0, 3.0, 3.5
  • You can’t target 2007 specifically and use anything but .NET 3.5
  • Only .NET 3.5 supports deploying VSTO solutions using ClickOnce

As I write this, I’m testing using IIS 7 running under Vista (yes, I’m a glutton for punishment) for my publishing location and have Windows XP running under Virtual PC with Office 2003 for testing the deployment. So far I’ve had several attempts at getting the bootstrap to download and install .NET 3.5 and the VSTO runtime. To work around a couple of the problems I had to manually add application/octet-stream MIME types to IIS for the .MSP and .MSU files that are part of the .NET Framework redistributable.

Everything is downloading now, but the install failed with a “Status of package ‘.NET Framework 3.5’ after install is ‘InstallFailed'” in the installer log file. I’ll update this post once I get that figured out…

UPDATE: Rebooted the VPC and now the .NET Framework installed. Gotta love it.

UPDATE: Needed another MIME type set up for .vsto files:

UPDATE: And after all of that, it doesn’t work with Excel 2003. I get the error: The common language runtime could not be loaded by Excel file path. Contact your administrator for further assistance. I thought maybe if I used the Office 2007 VSTO project template, but saved the Workbook using the 97-2003 compatible format I could open it in Excel 2007 or 2003. No such luck. Looks like if you want to use VSTO + ClickOnce, you have to target Office 2007 users…

3 thoughts on “Crash Course in VSTO”

  1. Jim,
    I encountered the same CLR loading error (with Word). I’ve been developing this one solution for the past 10 months and never saw it before. Funny, it chose to show up 2 hours before I’m off on a 3 week vacation. Good times!

    Were you able to solve it?

  2. No, I haven’t solved it. The only thing I’ve been able to get to work is an Excel 2007 project using .NET 3.5 and ClickOnce. And to get THAT to work you have to modify the settings in the “trust center” to trust documents from the network and add the URL to the deplotment site.

    I love the ability to use .NET in Office apps (instread of crusty old VBA), but the deployment story stinks.

  3. I have a blog post regarding deploying a VSTO solution when using two zones (MyComputer and LocalIntranet) It’s not too bad once you wrap your head around the concepts. But getting comfortable with the CAS system itself was a bit of a doozie.

Comments are closed.