【发布时间】:2019-04-29 17:08:27
【问题描述】:
这是一个用于与正在运行的 Outlook 应用程序交互的 sn-p。
Try
OutlookObj = System.Runtime.InteropServices.Marshal.GetActiveObject("Outlook.Application")
Catch ex As Exception
Console.WriteLine("Something went wrong while trying to connect to Outlook. Make sure Outlook is running. Press any key to exit.")
Console.Read()
Exit Sub
End Try
OutlookInspectors = OutlookObj.Inspectors
AddHandler OutlookObj.NewMailEx, AddressOf OutlookObj_NewMail
这是我的新消息事件处理程序。
Private Sub OutlookObj_NewMail(ByVal ID As String)
Dim Item As Microsoft.Office.Interop.Outlook.MailItem = OutlookObj.Application.Session.GetItemFromID(ID)
'Further processing...
End Sub
问题是,它挂在GetItemFromID 上。最终,我会得到一个ContextSwitchDeadlock 异常。 Office 是 2016(365 专业增强版,x64,版本 1808)。 Windows 10 1809。互操作是版本 15。尝试在 AnyCPU 和 x64 下运行我的应用程序。
【问题讨论】:
标签: vb.net outlook office-interop