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

时间:2011-07-13 14:44:32

标签: c# visual-studio-2010 ms-office outlook-addin office-interop

我正在使用Visual Studio 2010创建Outlook 2010 Add In。我尝试创建一个新的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有关。

3 个答案:

答案 0 :(得分:3)

您是否安装了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

答案 1 :(得分:2)

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

答案 2 :(得分:1)

以下是我通常对我需要的所有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);

与上述解决方案类似。

相关问题