Strange Behaviour of Explorer Object.

  • Thread starter Thread starter JIGNESH
  • Start date Start date
J

JIGNESH

Since I can;t Post images here. Please refer to following url for Image.
http://accenture.dotnetjini.com/OutLookAddInError.jpg

In Explorer DeActivate Event i am calling This.Application.ActiveExplorer().
It does not return null, but if i query its Selection Property it throws an
exception.

I am surprize to see that for other properties there is no exception
generated. (as seen in image)

Why is this behaviour, I don;t understand. is it because of poor outlook API?

The Details of error is.
System.Runtime.InteropServices.COMException occurred
Message="The Explorer has been closed and cannot be used for further
operations. Review your code and restart Outlook."
Source="Microsoft Office Outlook"
ErrorCode=-624820215
StackTrace:
at Microsoft.Office.Interop.Outlook.ExplorerClass.get_Selection()
at
OutlookAddIn3.ThisAddIn.wrappedExplorer_ExplorerDeActivate(MailItem
p_currentMailItem) in D:\2009Trainings\outlookTest\ThisAddIn.cs:line 242
InnerException:


Please advice.

Regards
 
The state of ActiveExplorer() during Deactivate() is going to be
indeterminate. Why do you need the Selection collection then?

Why not on Activate() and then handling selection changes in the
SelectionChange() event?

Or you can get a handle to that specific Explorer on Activate() and use that
instead of ActiveExplorer().
 
Back
Top