How to package an Visio Add-in

Started by yoursashok, April 05, 2010, 06:15:35 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

yoursashok

Hi,

I have created a Microsoft Visio Add-in using Microsoft Visual Studio. I want the Add-in exe to be installed on a target PC where Microsoft Office Visio is installed. Should I package the required dll along with the exe or can I exclude the required dll's and get their reference's from the target PC?. If I can exclude the dll's how can I get the reference of the Visio and Office API's like CommandBar etc.,. My Initial attempt excluding the dll's ends with an exception. It says the System cannot find the path specified for the assembly.

It will be better if someone point me to the way of accessing the installed API reference without bundling the dll's using C# code.

Thanks,
Ashok.

Nikolay

Hi Ashok,

1. When you create a project in VS, installer project is created automatically for you.
Means, is there something wrong with it?

2. If your add-in is a "shared add-in", and does not use VSTO (Visual Studio Tools for Office), then AFAIK you are not supposed to either install or generate interop dlls yourself. When you install Office, interop dlls are installed in GAC on target machine.

3. If you did use VSTO to create your addin, then most probably you need ship VSTO dlls as well.
I'd recommend you google on "deploy VSTO addin"

Regards, Nikolay.

yoursashok

Hi Nikolay,

Thanks for the response. Yes, I'm using VS and the installer packages the dll's to it if I build the solution. I want to avoid packaging those dll's and make use of the ones that gets installed along with the Microsoft Office and Visio where the add-in will be installed. My requirement is to identify the Office Core and Visio dll's installed in the target PC instead of bundling them along with the Installer.

I use the Visual Studio Shared Add-in approach. I'm using the CommandBar related classes from the Office Core dll. You had mentioned that it will get installed in GAC, is there a way to refer to that dll after the add-in is installed in the target PC?

Let me know if you need more details from my side.

Regards,
Ashok.

Nikolay

As far as I understand, you don't actually need to "refer" to those assemblies specifically on target machine... The references to interops are "burned" into your add-in DLL on build. Means, if (on your development machine) your project references normal Office PIAs, then you shall just build your project, then build your installer (containing your DLL only), and then install it on then target machine... You add-in will bind to visio-installed PIAs automatically. That's it. All interop assemblies (including Interop.Office.Core with command bars you mentioned) can be excluded from your setup, because they are supposed to be already pre-installed by Visio setup in GAC.

NB: Visio must be installed with .NET programmability support turned on on target machine (which is default, as far as I remember).
Means, this exactly feature (flag) of Visio setup installs the PIAs.

Summarizing, I don't think you need to do anything extra for a shared add-in.
You just build your add-in against office-shipped PIAs, include in setup your add-in DLL only, and you are done :D

The things might become more complex in case if you need to support more than one version of Visio (multi-version targeting), or use VSTO.

Some more info on installing PIAs:
http://msdn.microsoft.com/en-us/library/aa159923.aspx

NB: A great deal of help for testing installers are virtual machines (like Microsoft Virtual PC, or virtual box, VMWare). First you do a "clean" install of operating system to the virtual machine, then do clean install of the Visio application, then make a "snapshot". Now, you will be able verify your installer works properly on this virtual machine as many times as you like.

One more side note:
.NET 4.0 greatly simplifies multi-version targeting by allowing "no-pia" deployment! Means, PIAs are no longer required for .NET 4.0. Video about that:
http://channel9.msdn.com/posts/Charles/Raja-Krishnaswamy-and-Jesse-Kaplan-CLR-4-Inside-No-PIA/

Kind regards, Nikolay.

yoursashok

Hi Nikolay,

Thanks again for the response. What I noticed is that the source patch of the Interop.Microsoft.Office.Core is set to the "C:\Documents and Settings..." folder. Whereas the source path of the Microsoft.Office.Interop.Visio is set to the Global Assembly Cache path "C:\WINDOWS\assembly". I had set the Copy Local property to False for the Office.Core assembly. Even then I'm getting the following exception when the Add-in is loaded,

4/5/2010 7:42:38 PM: Could not load file or assembly 'Interop.Microsoft.Office.Core, Version=2.3.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified..

From my understanding, I believe this occurs while trying to create a new Menu Bar using the CommandBars class. All I did was to include the reference of the Office Object Type library and Visio library. It makes me to think that the Visio dll is referred correctly but it is not the case of the Office.Core dll. Sorry I'm new to .NET development. Let me know if you can can figure out something from this.

Thanks  again for the details. Will look at them.

Regards,
Ashok.

yoursashok

Hi Nickolay,

After removing office core dll reference and re-adding it, I was able to get it working in my PC. Will check in other PC's and let you know.

Thanks,
Ashok.