Search code examples
vb.netvisual-studiovstoopenxmloffice-interop

Adding Open XML References to a Visual Studio Project


I am adding Open XML functionality to an Office VSTO add-in built in Visual Studio 2012 and 2010. This requires adding two references to my VS project: DocumentFormat.OpenXml.dll and WindowsBase.dll. My concern is that these DLLs won't be present on end users' computers, and the code will throw an error when run on their computers. Two questions:

1) Is it safe to assume that these two DLLs are present on my users' PCs (just like I can safely assume that System.Xml.dll is)? Do they install automatically with Windows and/or Office, or are they included in some sort of Windows/Office update that everyone generally has installed?

2) If not, what is the best way to ensure that my add-in will run on their computers? Do I need to include these as prerequisites in my installer? Set the CopyLocal property = True?

I did find this similar question on SO:

Is OpenXML SDK required to be installed in every computer that will run my program?

but the entering assumption is that CopyLocal is already set to True. I would prefer avoid that if possible. Also, the solution is not really a solution because the author says no action is required. Vallo's comment to the accepted solution seems more helpful, but it appears to require unintuitive additional action by the end user that I want to avoid.


Solution

  • DocumentFormat.OpenXml.dll is part of the Office Open XML SDK. There's no reason for your clients to install the whole SDK.

    So yes, you have to ship DocumentFormat.OpenXml.dll to them by setting CopyLocal to True.

    WindowsBase.dll is part of the .NET Framework so you don't have to manually include this one.