Microsoft.Office.Interop.* 版本 12 和 14 之间有什么区别?
我已经安装了 Visual Studio 2010 和 Office 2007。当我转到“添加引用”并搜索“Office Interop”时,我可以看到每个引用在版本 12 和 14 中出现两次。
我最初尝试了 Microsoft.Office.Interop.Word
版本 14 并进行了快速测试。初始化应用程序,打开文档,关闭文档,退出应用程序,并释放COM对象。我的测试是 C# 4.0 中的一个简单的 WinForms 程序。
关闭文档时 WINWORD.EXE 崩溃。
我将参考切换到版本 12,并将代码保持原样,然后再次尝试。一切都很好。
此后我使用版本 12 编写了其余的代码,并且没有遇到任何问题。
所以现在我很好奇:版本 12 和 14 中 Microsoft.Office.Interop.*
中公开的成员之间存在一些细微差别,但很大程度上存在很多重叠。
实际的区别是什么?为什么即使我有相对较新版本的 Office,我的简单测试也会失败?开发人员在启动互操作项目时应选择哪个版本,是否有经验法则?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
版本 12 是 Office 2007 的互操作,而 14 是 Office 2010 的互操作。据我所知,除非您确实需要第 14 版本的一些新功能,否则您可以使用较低版本的互操作库,它适用于所有较新版本的 Office。
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.