QueryInterface for interface Microsoft.Office.Interop.Outlook._AppointmentItem failed

  • Thread starter Thread starter asaf lahav
  • Start date Start date
A

asaf lahav

Hi all,

I had just encountered a strange exception on my VB.NET outlook XP addin.
I'm handling the Add and Change events of the outlook default calendar.
And in some situations I'm getting this exception:

"System.InvalidCastException: QueryInterface for interface
Microsoft.Office.Interop.Outlook._AppointmentItem failed.
at Microsoft.Office.Interop.Outlook.AppointmentItemClass.get_BusyStatus()
at SESchedulerAddIn.Connect.m_calendarAppointmentItems_ItemChange(Object
Item) in C:\Work\Mercury\SE
Scheduler\Development\SEScheduler\SESchedulerAddIn\Connect.vb:line 1557"

The code that triggers this exception is functioning well... but when I
sometimes change fields on an appointment, it fires that exception.

The Code section which throws the exception:

If (TypeOf (Item) Is Outlook.AppointmentItem) Then

Dim appt As Outlook.AppointmentItem = CType(Item, Outlook.AppointmentItem)

If Not appt.BusyStatus = Outlook.OlBusyStatus.olTentative Then

'here I do something that doesn't have anything to do with the outlook
object.

End If



If Anyone has any idea... (and I do mean any... because I'm out) Please
HELP!

Asaf Lahav
 
Hi All,

I finally found out what was the reason I got the exception.
Since I'm handling the Add and Change events on the calendarFolder, i'm
getting a changed event on the calendar folder when a meeting cancellation
is committed.
I assume the item parameter i'm getting into the event simply points to an
invalid appointment item (probably since that change that is being committed
is actually a 'DELETE').
If you ask me its an absurd!
The Change event item i'm getting is not supposed to be deleted yet....
Anyhow, i'm successful in casting the object i'm getting to an
AppointmentItem, and i'm able to extract the item 'Subject' property.
But attempting to access any other AppointmentItem Property of method
results in the following exception:

System.InvalidCastException: QueryInterface for interface
Microsoft.Office.Interop.Outlook._AppointmentItem failed.
at Microsoft.Office.Interop.Outlook.AppointmentItemClass.get_BusyStatus()

The question is.... how can I know the item change event i'm getting in
triggered because meeting cancellation prior to the exception being thrown?

Asaf
 
Back
Top