如何提高 VSTO2SE MS Office 加载项的冷启动性能?
如果您创建一个针对 Microsoft Office Excel 2003 的简单“Hello World”VSTO2SE 加载项,则冷启动时加载需要 15 秒。 在此期间,Excel 完全没有响应。
Excel 2003 的冷启动时间总是很短。我见过一台测试机,在 Excel 2007 中启动时间很快,但我的所有其他测试机都需要 15 秒才能初始化。 (测试环境-windows xp pro + VSTO2SE运行时 + XP SP3)
这个性能如何提升呢?
我已经尝试过但没有成功的事情:
禁用 CRL(证书撤销列表)检查 - 这似乎没有帮助,而且我不能指望用户这样做。
使用 NGEN 创建本机程序集。
a) Office 2003 似乎从不使用本机程序集。 b) 我的 Office 2007 测试客户端启动速度很快,即使使用 IL 程序集也是如此。 c) 即使我 NGEN 整个依赖关系树,仍然存在可能没有本机映像的 VSTO 依赖项。延迟加载加载项 - 这是我从 Microsoft 获得的解决方法“库存响应”。 问题是,我的加载项是从菜单项启动的 - 如何延迟加载加载项并仍然获取我的菜单? 我可以使用 VB6 插件来绘制菜单并通过互操作转发调用,但是为什么我要首先编写 VSTO 插件呢?
编辑 - 是的,这是加载项中“连接”事件的唯一一行。 (实际上是消息框).. 花了整整15秒才出现消息框。 ——J·戴维斯
If you create a simple "Hello World" VSTO2SE add-in targeting Microsoft Office Excel 2003, it takes 15 seconds to load on a cold startup. During that time, Excel is completely unresponsive.
The cold-startup time is always poor in Excel 2003. I have seen one test machine where the startup time is instant in Excel 2007, but all my other test machines take 15 seconds to initialize. (test environment - windows xp pro + VSTO2SE runtime + XP SP3)
How can this performance be improved?
Things I've already tried with no success:
Disasble CRL (certificate revoke list) checking - this doesn't seem to help, plus I can't expect users to do this.
Use NGEN to create native assemblies.
a) It seems that Office 2003 never uses the native assemblies.
b) My office 2007 test client that starts fast, does so even with IL assemblies.
c) Even if I NGEN my entire depencency tree, there are still VSTO dependencies that may not have native images.Delay load the add-in - this is the workaround "stock response" i get from Microsoft. The thing is, my add-in is launched from a menu item - how can I delay load the add-in and still get my menus? I could use a VB6 add-in to draw the menus and forward the calls via interop, but then why would I even write a VSTO add-in in the first place?
Edit - Yes, that is the only line on the "connection" event in the add-in. (actually messagebox).. It takes a full 15 seconds before the message box appears. – J Davis
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将在冷启动时受到影响,因为它必须第一次加载所有程序集。
如果热启动明显更快,那么您唯一真正的选择是
1) 在 Windows 启动时加载单独的程序,并在后台加载您的插件的所有程序集。
2)尝试减少正在使用的组件数量。 当然,您不应该过多地使用 Hello World。
3) Excel 启动时预加载所有内容。 这会影响 Excel 的启动时间,但会使您的菜单选择速度更快。 您还可以在后台预加载所有内容,以帮助实现此目的。
You're going to take a hit on cold start up because it has to load all of the assemblies for the first time.
If warm start up are significantly faster, then the only real options you have are
1) Have a separate program load when windows starts and load all of the assemblies for you r addin in the background.
2)Try to reduce the number of assemblies you are using. Granted, you shouldn't be using much with Hello World.
3) Preload everything when Excel starts. This will hurt Excel start up time, but will make your menu selection speedier. You could also preload everything in the background, to help this.
您是否已验证实际的滞留情况是什么? 如果您将 Debug.Write() 语句作为 VSTO 插件中的第一行,是否需要 15 秒才能显示在调试窗口中?
我们正在使用 VSTO,每当遇到阻碍时,通常是实际运行时间以外的其他原因导致速度减慢。 我们通过分离后台线程来执行缓慢的操作,同时不阻塞主线程(这会阻止 Excel 启动)来解决此问题。
附: 我们也不是 VSTO 技术的忠实粉丝。 我们 100% 认同这一愿景,但实施过程中还有很多不足之处。
Have you verified what the actual holdup is? If you put a Debug.Write() statement as the first line in your VSTO addin, does it take 15 seconds to show up in the debug window?
We're working with VSTO and whenever we have holdups, it's usually something other than the actual runtime that's causing the slowdown. We've solved this problem by spinning off background threads to do the slow things while not blocking the main thread, which holds up Excel startup.
ps. We're also not huge fans of the VSTO technology. We're 100% bought into the vision, but the implementation leaves alot to be desired.