Outlook 2010 COM hresult: 0x80040155 Exception on c# app, but only on my Workstation

0

We have a c#-4.0 Click Once WinForm application with a DataGrid that displays a list of .msg files that have been saved on our file server, and when the user double clicks on a row in the grid, it opens the corresponding .msg file. This app is deployed to over a dozen workstations (all running W7 64Bit Pro with Outlook 2010) and it works without issue, I'm the only one getting this exception so the issue appears to be with Outlook on my workstation and not necessarily the app.

The Namespaces used on the form that contains the DataGrid:

using Office = Microsoft.Office.Core;
using Outlook = Microsoft.Office.Interop.Outlook;
using System.Net;
using System.Net.Mail;
using System.Runtime.InteropServices;
using System.Net.Mime;
using System.Globalization;

The References in the Visual Studio 2010 Project:

  • Microsoft.Office.Core Microsoft.Office.Interop.Outlook (Verson 14.0.0.0)
  • Microsoft.Office.Interop.Word Microsoft.Office.Tools.Common.v4.0.Utilities
  • Microsoft.Office.Outlook.v4.0.Utilities

In the GridView's DoubleClick event:

Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();

// The following line is where the exception is thrown.
Microsoft.Office.Interop.Outlook.MailItem mail = (Microsoft.Office.Interop.Outlook.MailItem)oApp.Session.OpenSharedItem(Settings.Default.msgFilePath + @"\SL_Imported_Files\Customer\OLI\PA\SL_Int_" + inID + ".msg");
if (mail != null)
    mail.Display(false);

Marshal.ReleaseComObject(mail);
mail = null;

The Exception Message:

{"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: Interface not registered (Exception from HRESULT: 0x80040155)."}

I've checked the accepted answer from this thread and my HKEY_CLASSES_ROOT\TypeLib\{00062FFF-0000-0000-C000-000000000046} is 9.4, also no other version of Outlook as ever been install on my workstation except for 2010

c#-4.0
com
interop
office-interop
outlook-2010
asked on Stack Overflow Apr 27, 2016 by Cornelius • edited May 23, 2017 by Community

1 Answer

0

It seems this was related to my old workstation and its Office install. I recently moved to a new workstation with a fresh Windows and Outlook 2010 install and this issue has disappeared.

answered on Stack Overflow Jul 4, 2016 by Cornelius

User contributions licensed under CC BY-SA 3.0