views:

113

answers:

1

I'm experiencing a bit weird problem with VSTO Outlook add-in I'm developing. It works fine on a bunch of machines but in one it throws an InvalidCastException and cannot find the reason why. I've checked that all prerequisites are installed on this machine (the installer doest it by itself but I also checked that manually) and everything seems to be exactly like on other machines.

The code throwing an exception is:

this.Application.Session.
    GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar).Items.
    OfType<Outlook.AppointmentItem>();

and the exception is:

Unable to cast COM object of type 'Microsoft.Office.Interop.Outlook.ApplicationClass' to interface type 'Microsoft.Office.Interop.Outlook._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063001-0000-0000-C000-000000000046}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).

Does anyone have any ideas what might be the problem?

A: 

Make sure you have VSTO runtime and correct version(OL2003/OL2007) of PIA installed..Some time it could be CAS policy problem http://msdn.microsoft.com/en-us/library/zdc263t0.aspx

Deepak N