3

我正在使用Visual Studio 2010創建Outlook 2010添加。我嘗試創建一個新的Outlook AppointmentItem,並認爲我可以最終將其添加到日曆中。80040154類未註冊Outlook 2010中的錯誤加入

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

但是,當AddIn運行並trys創建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。

+0

嘗試安裝/重新安裝outlook,從我在其他論壇上閱讀,這可能會做詭計 –

回答

2

異常消息是不是非常有幫助,他們可以做與COM申報工作做得更好。這是設計,班級沒有註冊。您必須使用Application.CreateItem()方法創建它的一個實例。

+0

具體來說,這是代碼現在看起來像什麼樣的工作 - 全局。 ThisAddIn.Application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem)' – kavun

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

+0

- 我確實安裝了Outlook 2010,但它是一個32位版本,我相信我的AddIn是64位,因爲我我正在開發一個64位系統。 - 我查看了OLE/COM Object Viewer,Microsoft Outlook 14.0 Object Library(版本9.4)的TypeLib Registry具有與錯誤中顯示的不同的GUID - {000062FFF-0000-0000-C000-0000000000} vs錯誤{00061030-0000-0000-C000-000000000046} – kavun

+1

嘗試尋找http://msdn.microsoft.com/en-us/library/gg549122.aspx –

1

以下是我通常用於所有Outlook互操作的對象,我需要做的:

// 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); 

它類似於上述方案。

相關問題