• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

bVisual

  • Home
  • Services
    • How Visio smartness can help your business
    • Visio visual in Power BI
    • Visio Consulting Services
    • Visio Bureau Services
    • Visio Training and Support Services
  • Products
    • Visio Shape Report Converter
    • SS Plus
    • LayerManager
    • visViewer
    • Metro Icons
    • Rules Tools for Visio
    • The Visio 2010 Sessions App
    • Multi-Language Text for Visio
    • Document Imager for Visio
    • multiSelect for Visio
    • pdSelect for Visio
  • Case Studies
    • Case studies overview
    • Using Visio in Education for GIS
    • Visualizing Construction Project Schedules
    • Visio Online Business Process Mapping
    • Nexans Visio Template
    • CNEE Projects, WorldCom
    • Chase Manhattan Bank
  • News
    • Recent news
    • News archive
  • Resources
    • Articles➡
      • ShapeSheet Functions A-Z
      • Comparing Visio for the Web and Desktop
      • Customising Visio Shapes for the Web App
      • Key differences between the Visio desktop and web apps
      • Using the Visio Data Visualizer in Excel
      • Using Visio in Teams
      • Creating Visio Tabs and Apps for Teams with SharePoint Framework (SPFx)
      • Designing Power Automate Flows with Microsoft Visio
      • Innovative uses of Visio Lists
    • Webcasts ➡
      • Visio in Organizations
      • My session and other Visio sessions at MSIgnite 2019
      • Power up your Visio diagrams
      • Vision up your Visio diagrams
      • The Visio 2010 MVP Sessions
    • Visio Web Learning Resources
    • Books➡
      • Visualize Complex Processes with Microsoft Visio
      • Mastering Data Visualization with Microsoft Visio
      • Microsoft Visio Business Process Diagramming and Validation
      • Visualizing Information with Microsoft Visio
  • Blog
    • Browse blog articles
    • Visio Power BI articles
    • Visio for Web articles
    • A history of messaging and encryption
  • About us
    • About bVisual
    • Testimonials
    • Bio of David Parker
    • Contact Us
    • Website Privacy Policy
    • Website terms and conditions
    • Ariba Network
You are here: Home / Visio / Deploying a Visio 2007 or 2010 VSTO add-in with Visual Studio 2010

Published on November 8, 2011 by David Parker

Deploying a Visio 2007 or 2010 VSTO add-in with Visual Studio 2010

I like extending Visio with custom code, and I have been doing it a long time. I progressed from VBA within Visio documents, to VB executable, using a C++ wrapper to register as Visio Add-ons, through VB.net COM add-ins to C# VSTO add-ins. Which ever language and method I use, it seems to me that deployment is always far more more difficult than it should be. Even though it has got simpler with VS 2010, there are still some gotchas…

I always seem to spend far too long creating a Setup and Deployment project for Visio solutions, so I thought I should document what is required (currently). I have clients who have Visio 2007 and Visio 2010, running on PCs that have .Net Framework 3.5 sp1 or .Net Framework 4, so I have to cater for all of these permutations. I do still have clients with Visio 2003 too, but that is another story (and I need to use VS 2008 to deploy to them).

I guess I should explain why I need to have different solutions for Visio 2007 and Visio 2010?: The answer is that even though the main code is the same for both, the UI handling is different because Visio 2007 has CommandBars and Visio 2010 has a Ribbon. I decided to do this by having two separate projects with shared code (and some compilation symbols). Therefore, I needed two different installations. Moreover, Visio 2010 is available as 32bit or 64bit, and, even though the code project can be targeted to either, you need to make a choice when you compile a Setup and Deployment project. So, I eventually ended up with three installation sets!

First of all, most Visio solutions involve deploying Visio documents, be it templates or stencils, so you will most probably want to use the Visio Solution Publisher ( see http://www.microsoft.com/download/en/details.aspx?id=12365 – note that it says it is for Visio 2010, but is actually for Visio 2003, 2007 and Visio 2010!). This tool works by modifying the msi file created by Windows Installer projects, therefore you will want to create a Setup and Deployment / Visual Studio Installer project that uses the primary project output from your add-in project.

There is an excellent video on the different requirements for targeting Office 2007 or Office 2010 and .Net 3.5 sp1 or .Net 4 ( How Do I: Deploy Office 2007 and Office 2010 Projects that Target .NET Framework 3.5 and .NET Framework 4? – http://msdn.microsoft.com/en-us/vsto/ff679933.aspx ), but it does not discuss the Setup & Deployment package that is required.

This article , Deploying a Visual Studio 2010 Tools for Office Solution Using
Windows Installer
– see http://msdn.microsoft.com/en-us/library/ff937654.aspx, explains the requirements and the components of the Setup & Deployment package. Note that it discusses additional requirements for document level solutions, but generally Visio solutions do not need this because we have the Visio Solution Publisher tool.

You can also see the article Publishing an Office Solution by Using Windows Installer – http://msdn.microsoft.com/en-us/library/cc442767.aspx for an overview.

Chris Hopkin’s blog, A Complete Solution for Visio 2010 and Visio Services – http://blogs.msdn.com/b/chhopkin/archive/2010/05/28/a-complete-solution-for-visio-2010-and-visio-services.aspx, is useful because it is Visio-specific, but is aimed at Visio Services, and his earlier blog Deploying a VSTO 3.0 based Visio add-in using Windows Installer – http://blogs.msdn.com/b/chhopkin/archive/2008/11/13/deploying-a-vsto-3-0-based-visio-add-in-using-windows-installer.aspx is now out of date, but still useful.

A walkthrough of a simple Visio Setup and Deployment project

I created a very simple VSTO add-in using C# and .Net Framework 3.5 sp1.

image

So, the Target framework is .Net Framework 3.5:

image

I have gone to the trouble and expense of purchasing a digital certificate, so that my users can be sure that it comes from me, and the add-in does not need to be installed in the Program Files path. The Timestamp server URL is provided by Verisign too:

image

As this solution will be using the local vsto files, I ensured that the Publish Options / Office Settings were something sensible:

image

I needed to ensure that the Microsoft Office 2007 Primary Interop Assmblies are ticked in the Publish/ Prerequisites dialog. This is required for .Net Framework 3.5 only. In addition to including the relevant .Net Framework, you also need to include Microsoft Visual Studio 2010 Tools for Office Runtime and Windows Installer 3.1 for both frameworks.

image

The only code added to my add-in shows a message box when the add-in starts, and another when it closes….

namespace Visio2007OnXp35AddIn
{
    public partial class ThisAddIn {
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            System.Windows.Forms.MessageBox.Show("Loaded .Net 3.5 addin", "Visio2007OnXp35AddIn");
        }

        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {
            System.Windows.Forms.MessageBox.Show("Unloaded .Net 3.5 addin", "Visio2007OnXp35AddIn");
        }

Now, when you run the add-in in Debug mode, some entries get written into the Registry under the HKCU\Software\Microsoft\Visio\Addins hive.

image

All this example project does is open a dialog to prove it is loaded:

image

And when Visio is closed down, the Unloaded message box appears:

image

After running in Debug mode, you can view the Registry entries that get written (note that you may need to select View \ Refresh first):

image

The FriendlyName is derived from Publish Options / Office Settings / Solution Name, and Description is derived from Publish Options / Office Settings / Description.

Note that HKLM does not get written to by running the Debug mode.

You can return the Registry back to its original state by choosing Clean from the right mouse menu of the Solution explorer in Visual Studio. If you want to test the installation on your development PC later, then it is important that you do use Clean first.

So, I then added a new Setup and Deployment project to the solution, and edited the DetectNewerInstalledVersion, Manufacturer, ProductName and RemovePreviousVersions poperties:

image

Note that you CAN set the InstallAllUsers to True for Office 2010 solutions, but it must be False for Office 2007. This took me two days to realise recently!

Note that the TargetPlatform is x86 – when it comes to creating the Visio 2010 installations, I run it once as x86 and then again as x64.

In this case, all of the Detected Dependencies can be marked as Exclude = True.

image

Now, you need to switch to Release mode and run the project because this will create the *.vsto and *.dll.manifest file in the bin/Release folder. This are needed because you need to add them as files to the File System / Application Folder of the setup project. (Note that these two files will get deleted when you run Clean – as will the Registry entries).

image

So, there are only three files that will be deployed to the target folder on installation. (Note that there are often templates and folders added to this list in a Visio solution).

image

Now, you need to create the Registry keys that are required for Visio to recognise the dll as a Visio add-in. These entries are only required to be added to the User/Machine hive in the Registry window of the Setup and Deployment project. Note that these are very similar to the Registry entries that were added automatically when the code was run in Debug mode, but I have added my company name as a prefix to the addin name key – just to ensure uniqueness.

image

UPDATE : Sice I wrote this article, I came across an issue which was fixed by reading http://msdnrss.thecoderblogs.com/2011/06/vsto-4-0-sp1-will-cause-a-vsto-addin-to-not-find-its-config-file/

Basically, I added file:/// before [TARGETDIR] in the Manifest setting… then it worked again.

Note that you can delete the two Software keys that are automatically created under the HKCU and HKLM hive above.

You should check that the same Prerequisites are selected for the Setup project Property Pages:.

image

The minimum launch conditions are for the .Net Framework, but the articles describe how to add conditions for the Office 2007 Shared PIA, Visio 2007 , and VSTO 2010 Runtime.

image

Then, when you Build the Setup project, the output is created within its Release folder by default:

image

I ran the Setup.exe file, knowing that this will load the bootstrapper, which would install the Office 2000 PIAs, if required, but on my first attempt to install, I checked the option to install for Everyone.

image

However, the add-in failed to load the expected dialog, and opening the Tools / Trust Center / Add-ins tab showed that the add-in is present but inactive.

image

The solution is simple … do not install for Everyone if it is for an Office 2007 add-in – it is OK for Office 2010 ones though.

Then I got prompted to install the Office customization when I started Visio (I did not get prompted for this on subsequent installation tests on this PC).

image

This time, I found the add-in appeared correctly as an Active Application Add-in

image

The installation correctly installed the required files into the target folder:

image

The installation correctly created the Registry entries in the HKLM hive:

image

Well, that demonstrates how I publish Visio solutions to Visio 2007 and Visio 2010 separately. Perhaps I’ll discuss the settings in the Visio Solution Publisher  at another time….

Related

Filed Under: Visio Tagged With: Setup and Deployment, Visio 2007, Visio Solution Publisher, VSTO

About David Parker

David Parker has 25 years' experience of providing data visualization solutions to companies around the globe. He is a Microsoft MVP and Visio expert.

Reader Interactions

Comments

  1. Michael says

    November 8, 2011 at 11:59 am

    nice post! thanks. I am still developing VSLs using Graham Widemans VBVSL adapter using VB, but need to migrate to something else to support Visio 2010 64-bit mode, but support Visio 2003 at the same time… 🙁

    Log in to Reply
    • davidjpp says

      November 8, 2011 at 12:19 pm

      Glad you liked it … I still have to make this code work for Visio 2003, so I will report my process later….

      Log in to Reply
      • JakeS says

        April 12, 2012 at 5:50 pm

        David, really appreciate the post, found it very useful. I was curious if you had 2003 visio version working. We are struggling getting that process to work.

        Log in to Reply
        • davidjpp says

          April 12, 2012 at 7:37 pm

          Jake,
          If I remember correctly, there was more to do with Visio 2003. I used to use VS 2005 SE, and I followed Chris Catillo’s article at http://blogs.msdn.com/b/chcast/archive/2007/03/28/creating-visio-add-ins-with-vsto-2005-se.aspx
          I just noticed Matk Nelson’s answer at http://www.visio-answers.com/microsoft/Visio-Developer/31809188/visio-2003-addon.aspx …

          Log in to Reply
  2. Michael says

    November 8, 2011 at 2:13 pm

    it’s not clear to me yet wether I need Visual Studio 64 bit and Visio 64 bit to develop or if 32 bit versions are enough… ?

    Log in to Reply
    • davidjpp says

      November 8, 2011 at 2:20 pm

      I have just looked on my Virtual PC, which has Windows XP, VS 2010 and Visio 2010 32bit … the options to build the Deployment Project for x86 or x64 are still there, so I think VS 2010 (which is 32bit anyway but with some 64bit extensions) and Visio 2010 32bit would seem to be OK for development … there are some special considerations for VBA on 64bit Visio, but that is out of scope here.

      Log in to Reply
  3. Chris Roth (Visio Guy) says

    November 14, 2011 at 1:39 pm

    Thanks David,
    This is a great reference for a set of problems that have been real thorns to many of us!

    Log in to Reply
  4. officemacro says

    November 18, 2011 at 6:58 pm

    Thanks for good stuff!
    Little tip: add-in code could look better if use shortcode “sourcecode” instead of “pre” tag.

    Log in to Reply
    • davidjpp says

      November 18, 2011 at 7:01 pm

      Thanks for the tip 🙂

      Log in to Reply
  5. andreas says

    January 18, 2012 at 1:53 pm

    Hi,
    Another tip: if you use .net 4.0 (client) for your AddIns and install the AddIn under the ProgramFiles folder, you don’t get the first time message to install the AddIn.

    Log in to Reply
  6. Robert Cowham says

    October 24, 2012 at 7:03 pm

    I am a satisfied customer of http://www.add-in-express.com/ – makes working with various versions of Visio (and indeed other office apps) pretty simple, and supports 64 bit as well if you want.

    They have wrapped the ribbon stuff for >=2010 and the menu stuff for <=2007.

    Log in to Reply
    • Robert Cowham says

      October 24, 2012 at 7:05 pm

      p.s. their deployment options are pretty good too, though the difference between one-click and two-click etc can be less than obvious…

      Log in to Reply

Trackbacks

  1. 安裝 Outlook Addins 到所有使用者 | 不認真寫部落格 says:
    February 17, 2013 at 7:21 am

    […] Deploying a Visio 2007 or 2010 VSTO add-in with Visual Studio 2010 […]

    Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

  • LinkedIn
  • Twitter

Recent Posts

  • Co-authoring and Commenting with Visio Documents
  • Fixing dimensions of 2D shapes
  • Merging Linked Data from Similar Tables
  • Smart Radio Buttons and Check Boxes in Visio
  • Using Button Face Ids in Visio

Categories

Tags

Accessibility Add-Ins Connectors Containers Data Export Data Graphics Data Import Data Visualizer Educational Excel GraphDatabase Hyperlinks Icon Sets JavaScript LayerManager Layers Legend Link Data to Shapes Lists MSIgnite MVP Office365 Org Chart PowerApps PowerBI PowerQuery Processes Setup and Deployment Shape Data Shape Design ShapeSheet ShapeSheet Functions SharePoint 2013 SQL Teams Validation VBA Video Visio Visio 2007 Visio for the Web Visio Online Visio Services Visio Viewer Webinar

Footer

bVisual Profile

The UK-based independent Visio consultancy with a worldwide reach. We have over 25 years experience of providing data visualization solutions to companies around the globe.

Learn more about bVisual

  • Amazon
  • E-mail
  • Facebook
  • LinkedIn
  • Twitter
  • YouTube

Search this website

Recent posts

  • Co-authoring and Commenting with Visio Documents
  • Fixing dimensions of 2D shapes
  • Merging Linked Data from Similar Tables
  • Smart Radio Buttons and Check Boxes in Visio
  • Using Button Face Ids in Visio

Copyright © 2025 · Executive Pro on Genesis Framework · WordPress · Log in