[英]Outlook VSTO Crash And Ways to Reduce Memory Consumption
Hey Guys I am a newbie in office addin programming and now I am working on creating an addin for outlook. 大家好我是Office插件编程的新手,现在我正在为Outlook创建插件。 The purpose of this outlook addin is to fetch all incoming mails in each account's inbox and send them to my server.
此Outlook插件的目的是获取每个帐户的收件箱中的所有传入邮件,并将它们发送到我的服务器。 I've successfully done it with Microsoft.Office.Interop.Outlook , though I have some problems with it.
我已经使用Microsoft.Office.Interop.Outlook成功完成了此操作 ,尽管我遇到了一些问题。 Here is my code http://pastebin.com/TwnmrYeY and below are the problems
这是我的代码http://pastebin.com/TwnmrYeY ,下面是问题
I hope you guys can help me since I've been stuck pretty long in these stuffs. 我希望你们能对我有所帮助,因为我被这些东西困扰了很长时间。
Firstly, Outlook Object Model cannot be used on a secondary thread in an Outlook addin - starting with Outlook 2013, Outlook will raise an exception as soon as it detects access to one of its objects on a secondary thread. 首先,无法在Outlook插件的辅助线程上使用Outlook对象模型-从Outlook 2013开始,Outlook一旦检测到对辅助线程上的对象之一的访问,便会引发异常。 Note that external exes marshal all OOM calls to the primary Outlook thread even if in that exe OOM is used on a secondary thread.
请注意,即使外部exe在第二个线程上使用OOM,外部exes也封送所有对主Outlook线程的OOM调用。 To ve able to access various Outlook obejcts on a secondary thread, you need to use either Extended MAPI (C++ or Delphi) or the a wrapper like Redemption (its RDO family of objects can be used in secondary threads ).
为了能够访问辅助线程上的各种Outlook对象,您需要使用扩展MAPI(C ++或Delphi)或像Redemption这样的包装器(它的RDO对象系列可以在辅助线程中使用 )。
Secondly, while Application.Quit event mostly won't fire, you can still detect the last Explorer or Inspector closing (Explorer.Close nad Inspector.Close events) - as soon as the last Outlook window is closed, Outlook will exit. 其次,虽然Application.Quit事件通常不会触发,但是您仍然可以检测到最后一个Explorer或Inspector关闭(Explorer.Close和Inspector.Close事件)-一旦关闭了最后一个Outlook窗口,Outlook就会退出。 That can also help prevent Outlook for exiting: if yo uhold a reference to an Inspector or Explorer object (even if it is not visible), Outlook will stay running.
这也可以帮助防止Outlook退出:如果您拥有对Inspector或Explorer对象的引用(即使它不可见),Outlook将保持运行状态。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.