80040154 Outlook 2010中未注册ERROR的类添加

我正在使用Visual Studio 2010创建Outlook 2010添加。 我尝试创建一个新的Outlook AppointmentItem来考虑我最终可以将它添加到日历中。

Microsoft.Office.Interop.Outlook.AppointmentItem tempApp = new Microsoft.Office.Interop.Outlook.AppointmentItem(); 

但是当AddIn运行并尝试创建AppointmentItem对象时,我在上面的行中收到此错误。

 System.Runtime.InteropServices.COMException was unhandled by user code Message=Retrieving the COM class factory for component with CLSID {00061030-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). Source=mscorlib ErrorCode=-2147221164 

我可以做些什么来“注册课程”? 我猜这与某些方面的Microsoft.Office.Interop.Outlook.dll有关。

exception消息不是很有用,它们可以用COM声明做得更好。 这是设计,该类未注册。 您必须使用Application.CreateItem()方法创建它的实例。

您是否安装了Outlook 2010? 互操作程序集只是Outlook 2010 COM组件的.NET包装程序。此组件应注册为互操作才能工作。 此注册通常由拥有组件的应用程序(即本例中的Outlook)执行。

您可以尝试通过regsvr32实用程序注册组件,但必须知道包含该组件的DLL的名称。

从“开始菜单\程序\ MS Visual Studio xxxx \ Microsoft Windows SDK工具”中使用OleView(现在称为“OLE-COM对象查看器”)来查看已注册的组件。

并检查x86 / x64选项。 例如,您可能已注册此组件的32位版本和64位应用程序,反之亦然。

http://www.msoutlook.info/question/461

以下是我通常对我需要的所有Outlook Interop对象所做的事情:

  // In Global Properties public static Outlook.Application olook = new Outlook.Application(); // Outlook Application Object. // In Method Outlook.AppointmentItem olookAppointment = (Outlook.AppointmentItem)olook.CreateItem(Outlook.OlItemType.olAppointmentItem); 

它类似于上面的解决方案。