Outlook 2010 COM hresult:0x80040155 C# 应用程序异常,但仅在我的工作站上

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

我们有一个 c#-4.0 Click Once WinForm 应用程序,它带有一个 DataGrid,显示已保存在我们的文件服务器上的 .msg 文件列表,当用户双击网格中的一行时,它会打开相应的 .msg 文件。此应用程序已部署到十几个工作站(所有 运行 W7 64 位 Pro 和 Outlook 2010)并且它可以正常工作,我是唯一遇到此异常的人所以问题似乎出在我工作站上的 Outlook 和不一定是应用程序。

在包含 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;

Visual Studio 2010 项目中的参考资料:

在 GridView 的双击事件中:

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;

异常消息:

{"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)."}

我已经检查了来自 this 线程的已接受答案,我的 HKEY_CLASSES_ROOT\TypeLib\{00062FFF-0000-0000-C000-000000000046}9.4,除了 2010 版之外,我的工作站上也没有安装其他版本的 Outlook

这似乎与我的旧工作站及其 Office 安装有关。我最近搬到了一个新的工作站,安装了全新 Windows 和 Outlook 2010,这个问题已经消失。