问题
I have installed Visual Studio 2010 and Office 2007. When I go to "Add Reference" and search for "Office Interop" I can see that each of the references appear twice with versions 12 and 14.
I initially tried version 14 of Microsoft.Office.Interop.Word
and did a quick test. Initialise the Application, open a Document, close the Document, quit the Application, and release the COM object. My test was a simple WinForms program in C# 4.0.
WINWORD.EXE crashed while closing the document.
I switched the reference to version 12, and left my code exactly as it was and tried it again. Everything worked fine.
I have since written the rest of my code using version 12 and haven't had any problems.
So now I'm curious: There are some small differences between the publicly exposed members in Microsoft.Office.Interop.*
in versions 12 and 14, but largely there is a lot of overlap.
What is the actual difference? Why did my simple test fail even though I have a relatively new version of Office? and is there a rule-of-thumb as to which version should the developer choose when starting an interop project?
回答1:
Version 12 is interop for Office 2007, while 14 is for Office 2010. AFAIK, unless you really need some new features of 14th version, you can use a lower version of interop library and it will work fine for all newer versions of Office.
来源:https://stackoverflow.com/questions/7749310/what-is-the-difference-between-microsoft-office-interop-version-12-and-14