Unable to cast COM object of type 'System.__ComObject' error

R

Rémi

Hello all,

I have created an add-in which adds user properties to appointments. When I
try to recover these user properties from the calendar of other users, I use
the find method to recover all the appointments between a period of time of 3
months. Then, I browse the results to find if the properties meet the
criteria, I have the following error :

Unable to cast COM object of type 'System.__ComObject' to interface type
'Microsoft.Office.Interop.Outlook.AppointmentItem'. This operation failed
because the QueryInterface call on the COM component for the interface with
IID '{00063033-0000-0000-C000-000000000046}' failed due to the following
error: Not such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE)).

This error appears unpredictably. But when I restart Outlook, it appears on
different appointments.

My code is as following :

Outlook.Items appointements = calendar.Items;

object item = appointements.Find(this._searchFilter);
while (item != null)
{
try
{
Outlook.AppointmentItem appointment = (Outlook.AppointmentItem)item;
results.Add(appointment);
}
catch (Exception ex)
{
}
item = appointements.FindNext();
}

The error is raised on the following line : Outlook.AppointmentItem
appointment = (Outlook.AppointmentItem)item;


Thank you very much. I am a bit desperate

Rémi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top