Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)

1

I have a PC with MS Office 2010 installed while the MS Outlook is installed from Office 2007. On this PC the below code:

Microsoft.Office.Interop.Outlook.Application myOutlook = new Microsoft.Office.Interop.Outlook.Application();
string theName = myOutlook.Name;

results into the below exception:

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)).

I have deleted the below registry entry and the above code was working normally. As soon as the Windows Updates run, the below entry is inserted again and the above code raises the exception again. HKEY_CLASSES_ROOT\TypeLib{00062FFF-0000-0000-C000-000000000046}\9.4

1) The registry entry cannot be deleted from the application due to permissions

2) The two office versions are needed

3) The line "string theName = myOutlook.Name;" can be replaced by any line referencing the variable myOutlook with exactly the same result

4) The same code works perfectly on PCs with MS Office 2007 installed, including MS Outlook.

Any suggestion will be much appreciated.

c#
outlook
asked on Stack Overflow Feb 2, 2015 by Chris • edited Feb 2, 2015 by Soner Gönül

1 Answer

0

You can use the late binding tachnology which can help to avoid such exceptions. See Type.InvokeMember method for more information.

Do you have the Click2Run edition of Office 2010 installed on the PC?

answered on Stack Overflow Feb 2, 2015 by Eugene Astafiev

User contributions licensed under CC BY-SA 3.0