Gordon Prince
Guest
|
My Outlook Add-in now seems to be working flawlessly in my development environment. And for most of my users for a while. At least one of them, though, is having the problem of the Add-in responding to events 20-50 times, then it stops responding until Outlook is restarted.
I've mirrored the user's actions on my development system as much as possible and cannot get my development system to fail. When I remotely watch the user perform their tasks, the Add-in works properly for 10 minutes or more. But within an hour or two at least part of it stops working. Any ideas how to troubleshoot this type of problem?
The task that's not working is intercepting displaying an Outlook Note. Based on the body of the Note I call another procedure, then cancel displaying the Note.
Public Overrides Sub ProcessBeforeAttachmentRead(ByVal attachment As Object, ByVal e As AddinExpress.MSO.ADXCancelEventArgs)
If InterceptNote(attachment) Then
e.Cancel = True
End If
End Sub
Function InterceptNote(attachment) As Boolean
Const strMsg As String = "This will only work if InstantFile is open." & vbNewLine & vbNewLine & _
"Open InstantFile, then try this again."
Const strTitle As String = "InterceptNote() for "
Dim myAttachment As Outlook.Attachment = Nothing
Dim appAccess As Access.Application = Nothing
Dim myNote As Outlook.NoteItem = Nothing
Try
myAttachment = attachment
If Left(myAttachment.DisplayName, Len(strIFdocNo)) = strIFdocNo Then
Const strDoc As String = "Open InstantFile Document"
Dim lngDocNo As Long = Mid(myAttachment.DisplayName, 19)
If IsDBNull(lngDocNo) Or lngDocNo = 0 Then
MsgBox("The item does not have a DocNo.", vbExclamation, strTitle & strDoc)
Return False
Else
Try
appAccess = CType(Marshal.GetActiveObject("Access.Application"), Access.Application)
If Not appAccess.Visible Then appAccess.Visible = True
appAccess.Run("DisplayDocument", lngDocNo)
Marshal.ReleaseComObject(appAccess)
Return True
Catch
MsgBox(strMsg, vbExclamation + vbOKOnly, strTitle & strDoc)
End Try
Return False
End If
...
Finally
If olNameSpace IsNot Nothing Then Marshal.ReleaseComObject(olNameSpace) : olNameSpace = Nothing
If myNote IsNot Nothing Then Marshal.ReleaseComObject(myNote) : myNote = Nothing
If appAccess IsNot Nothing Then Marshal.ReleaseComObject(appAccess) : appAccess = Nothing
End Try
End Function
Any suggestions on troubleshooting this subtle problem greatly appreciated. |
|
Andrei Smolin
Add-in Express team
Posts: 18821
Joined: 2006-05-11
|
Hello Gordon,
You can add a number of debug messages to your code; use System.Diagnostics.Debug.WriteLine(). You collect the messages at run time using DebugView (see http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx).
Gordon Prince writes:
then it stops responding
What does this mean? You click a Ribbon button and nothing occurs? Do you have a message box or dialog box opened behind the Outlook window or in Access?
Andrei Smolin
Add-in Express Team Leader |
|
Gordon Prince
Guest
|
What does this mean? You click a Ribbon button and nothing occurs? Nothing occurs, but it's from the event not being intercepted the way it is supposed to be rather than clicking a button and nothing occurs.
The code should intercept the reading or display of an attached Note. When that happens, something else displays (from Access). What's going on is it does that 20-50 times, then instead of intercepting the display of the Note it displays the Note itself.
Also your comment gives me the idea that a button on the ribbon to carry out the function that reading the attachment is supposed to be doing might be helpful. I will add that to the Add-in and ask users to try that if the automated interception of reading the attached Note stops working.
I'll get DebugView running and see where that leads. But if you have any idea where I might be looking for code in the meantime, I would appreciate your thoughts.
I have a hunch this project is going to go to sleep for several days as today is the Thanksgiving holiday in the USA and no one will be at work until Monday.
Cheers. |
|
Andrei Smolin
Add-in Express team
Posts: 18821
Joined: 2006-05-11
|
Gordon Prince writes:
But if you have any idea where I might be looking for code in the meantime, I would appreciate your thoughts.
I don't have ideas. Debugging should provide more information.
Andrei Smolin
Add-in Express Team Leader |
|