Search code examples
vstooffice-interopoffice-addins

What is VSTO exactly?


I have a few add-ins for Excel and Word 2007-2016. And I don't understand a few things. My project use some dlls, like Microsoft.Office.Tools.Common, Office.dll, some excel, word and common interop's. And these files can be found in a few places at the same time, different versions of them (like program files, windows/assembly, windows/Microsoft.Net/assembly). So I don't know which version to use. And also, if user has VSTO installed, I suppose he has these files. So why do I need to provide them? What do we install exactly when we install VSTO? Which part is for what and which installation place is from which component? I think I don't do it right, because I found out that Excel loads two different versions of the same file at the same time.


Solution

  • Those are a lot of questions, and many of them depend very much on exactly what you provide with your solution...

    The case of the PIAs ("Office dlls") is relatively clear cut:

    • You do NOT need to (and should not) distribute the Office PIAs with a VSTO solution, with the possible exceptions of 2007 and 2010. In these versions, installing .NET support was optional and not default. That's why there are redistributables for these versions, and not for others. Your installer needs to check whether they're present (same as with the VSTO runtime and the version of the .NET Framework) and install only when necessary.
    • Office always installs the PIAs into the GAC and your solution will find them there. It makes no difference where you referenced them on your developer machine.
    • The PIAs in the GAC are only available via the COM tab in the Visual Studio dialog box for inserting references. Many .NET developers didn't find them there, so Microsoft delivers a (ONE) single set of PIAs with VSTO and copies them to a Visual Studio folder so that they'll show up in the .NET tab of the dialog box. The only problem with this is that you get only the set of PIAs for the version of Office that was "current" when that version of Visual Studio was released, meaning you may get the impression you can't develop against any other version because you don't find the PIAs in the .NET tab (but they will be in the COM tab).
    • Rule of thumb: Always, always develop your code using the earliest version of Office you plan to support. There are two reasons for this: 1) You can only use functionality that will be available to all versions of the Office application (Office is generally backwards compatible); 2) Office is designed to migrate references to older sets of PIAs to newer sets, but not the other way around.

    There's a good article on deployment pinned at the top of the VSTO forum on MSDN that "sorts" a lot of requirements for various versions of VSTO and Office: https://social.msdn.microsoft.com/Forums/vstudio/en-US/1666d2b0-a4d0-41e8-ad86-5eab3542de1e/deploying-office-solutions-to-end-user-computers?forum=vsto for add-ins targeting 2007-2010. For later versions, see the MSDN documentation: https://msdn.microsoft.com/en-us/library/bb386179.aspx