单击“发送”按钮后 Outlook 2003 邮件窗口冻结
我使用 VSTO + VS 2008 开发了一个 Outlook 2003 插件。
有一个 VB 6 应用程序可以创建 Outlook 邮件的实例,向其附加一个文档并向用户显示要发送的文档。
当用户单击“发送”按钮时,邮件窗口会冻结。它仅发生在生产机器上。
VB6代码如下:
Private Sub Command1_Click()
Dim objOlApp As New Outlook.Application
Dim objMailItem As Outlook.MailItem
Dim objAttachments As Attachments
Dim arrFilesToAttach(1) As String
Set objOlApp = New Outlook.Application
Set objMailItem = objOlApp.CreateItem(olMailItem)
Set objAttachments = objMailItem.Attachments
arrFilesToAttach(0) = Text1.Text
For l = 0 To 0
strTemp = arrFilesToAttach(l)
If strTemp <> "" Then
objAttachments.Add arrFilesToAttach(l)
End If
Next
objMailItem.Display True
Set objOlApp = Nothing
Set objMailItem = Nothing
Set objAttachments = Nothing
End Sub
查看是否是我的插件正在创建一个问题。我创建了一个简单的 Outlook 插件,并在 try...catch 块内的启动事件中添加了一些文件 IO 代码。我禁用了以前的插件并安装了这个新的示例插件。
结果令人惊讶,样本插件也造成了问题。它将示例插件的注册表中的 LoadBehaviour 更改为 2。 try...catch 块没有捕获异常。我已经为 Appdomain 的 unhandledException 添加了一个处理程序,但它也没有被解雇。
请帮忙...提前致谢。
I've developed an Outlook 2003 addin with VSTO + VS 2008.
There is a VB 6 application which creates an instance of Outlook mail, attaches a document to it and shows this to user to send.
When user clicks "send" button the mail window freezes. It happens on production machines only.
The VB6 code is as follows:
Private Sub Command1_Click()
Dim objOlApp As New Outlook.Application
Dim objMailItem As Outlook.MailItem
Dim objAttachments As Attachments
Dim arrFilesToAttach(1) As String
Set objOlApp = New Outlook.Application
Set objMailItem = objOlApp.CreateItem(olMailItem)
Set objAttachments = objMailItem.Attachments
arrFilesToAttach(0) = Text1.Text
For l = 0 To 0
strTemp = arrFilesToAttach(l)
If strTemp <> "" Then
objAttachments.Add arrFilesToAttach(l)
End If
Next
objMailItem.Display True
Set objOlApp = Nothing
Set objMailItem = Nothing
Set objAttachments = Nothing
End Sub
To see if it's my addin is creating an issue. I created a simple outlook addin and added some File IO code to the startup event Inside try...catch block. I disabled previous addin and installed this new sample addin.
The result was surprising, the sample addin too, was creating the problem. It changes the LoadBehaviour in registry to 2 for the sample addin. The try...catch block is not catching the exception. I've added an handler for Appdomain's unhandledException, but that too, is not getting fired.
Please help... Thanks in Advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 Outlook 将您的外接程序的加载行为更改为 2,这通常意味着该外接程序在加载过程中出现故障,并且 Outlook 正在禁用它。
插件在加载时可能出现故障的原因有各种各样(缺少引用的 dll、权限等),所以这是一个问题。
要确定您的插件是否挂起发送进程,只需禁用您的插件(例如将 loadbehavior 设置为 0)。实际上不需要为此创建一个示例插件。
如果禁用您的插件时一切正常,但启用它时失败,则插件中很可能存在问题。
那时,我所做的就是开始“发布”代码块。
我的意思是我开始注释掉入口点(或者注释掉所有入口点并一次仅取消注释一个)。
例如,如果您在启动事件中发生了一些事情,请将其注释掉,重新编译并测试。如果没有失败,请删除该评论,并评论链上更高位置的其他内容。
我还倾向于使用大量日志记录(通常使用 Log4Net,但您实际上可以使用任何东西)。
If outlook is changing the loadbehaviour to 2 for your addin, that usually means that something about that addin is faulting during the load, and outlook is disabling it.
there's all +kinds+ of reasons an addin could fault on load, (missing referenced dlls, rights, etc etc) so that's one issue.
To identify whether your addin is hanging up the send process, just disable you're addin (for instance set loadbehavior to 0). Not really any need to create a sample addin for that.
If things work right with your addin disabled, but fail with it enabled, there's very likely something wrong in the addin.
At that point, what I do is start "releasing" chunks of code.
What I mean is I start commenting out entry points (or comment all entry points out and uncomment just one at a time).
For instance, if you've got stuff happening in the Startup event, comment it out, recompile and test. If no failure, remove the comment, and comment something else higher up the chain.
I also tend to use a lot of logging (usually with Log4Net, but you can use anything really).