使用和不使用 VSTO 开发 Office 2007/2010 加载项的相对优点是什么?
几年前,我为 Office 2003(Word、Excel 和 PowerPoint)进行了一些非常认真的 Office 插件开发。我使用 Visual Studio 2003 在 C# 中创建了一些共享 COM 加载项。当时,我查看了 VSTO,但由于我不完全记得的原因,我决定它不适合我的需要。
我的加载项现在需要升级,不再需要支持 Office 2003 - 尽管它们仍然需要支持 Office 2007,而不仅仅是 2010。
我知道事情已经发生了重大变化,并且 Visual Studio 2010 具有更好的功能支持Office开发。我想确定是否应该使用 VSTO 重新实现我的加载项,或者继续使用共享 COM 加载项路线。
如果有人知道每种方法的优缺点的很好的总结(除了营销炒作之外),我很想听听。
我第一次发现非常令人沮丧的事情(没有使用 VSTO,但无论如何都可能适用):
- 需要显式管理 COM 引用(并调用 ReleaseComObject 随处可见)
- 需要 COM 填充程序才能使安全模型发挥作用
- Visual Studio 安装项目根本不起作用;我结束了 构建我自己的基于 MSI 的安装程序
- 缺乏文档,尤其是上述所有方面的文档;我花了 数周的反复试验和随机搜索博客; MS 提供的 示例代码完全忽略了所有这些现实问题
还值得一提的是,最大限度地减少在我的加载项之前需要安装的东西的数量很重要。我认为让我放弃 VSTO 的原因之一是需要部署额外的东西(尽管因为我从未走这条路,所以我不知道这种担忧是否合理)。我真的希望能够在标准 Windows 7(或 Vista)版本上进行部署,而无需首先安装(例如).NET 4。
Several years ago, I did some pretty serious Office add-in development for Office 2003 (Word, Excel and PowerPoint). I created some shared COM add-ins in C# using Visual Studio 2003. At the time, I looked at VSTO, but decided for reasons that I can't fully remember that it was not suitable for my needs.
My add-ins are due for an upgrade now, and no longer need to support Office 2003 - though they do still need to support Office 2007, not just 2010.
I know that things have moved on significantly, and that Visual Studio 2010 has better support for Office development. I'd like to determine whether I should re-implement my add-ins using VSTO, or continue with the shared COM add-in route.
If anyone knows of a nice summary of the pros and cons of each approach (beyond the marketing hype), I'd love to hear it.
Things that I found very frustrating first time around (not using VSTO, but may apply anyway):
- the need to manage COM references explicitly (and call
ReleaseComObject everywhere)- the need for a COM shim to get the security model to work
- visual studio installation projects just plain didn't work; I ended
up building my own MSI-based installer- lack of documentation, particularly on all of the above; I spent
weeks of trial-and-error and searching random blogs; the MS-supplied
example code completely ignored all of these real-world issues
It's also worth mentioning that minimising the amount of stuff that needs to be installed prior to my add-ins is important. I think that one of the things that put me off VSTO was the need to deploy additional stuff (though since I never went down that route I don't know if that concern was justified). And I'd really like to be able to deploy on a standard Windows 7 (or Vista) build without the need to first install (say) .NET 4.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
部分答案,但太长,无法容纳评论:
我可以评论的部分:
您没有指定用于创建这些 com 插件的内容(我猜测是 c++ 或 vb6),我无法判断它们有多大以及它们有多少大修需要,所以如果现在是做出改变的时候,实际上不可能提供建议。迁移到 c# 肯定会变得更加干净和更好的领域之一是与功能区相关的任何内容。但我再次无法估计这对你来说有多重要。
Partial answer but too long to fit in a comment:
Parts I can comment on:
You haven't specified what you used to create those com addins (My guess is c++ or vb6) and I can't tell how large they are and how much overhaul they need so it's not really possible to give advice if now is the time to make the change. One of the areas where moving to c# will certainly be far cleaner and nicer is anything related to ribbons. But again I can't estimate how relevant that is for you.