none
Retrieving the COM class factory for component with CLSID error 80040154

    Question

  • Hello,

    I created a Visual Studio 2010 Outlook 2010 Add-In with references to Interop.Excel and Interop.Outlook. Basically I have developed a new custom tab, with group and a button. In Button_OnClick I call a function from a Module. The code there creates a schema of the users appointments and attach the xl-sheet to an e-mail.

    When I hit F5 nothing happens in the Outlook that opens. I publish the solution and install it locally and when I open outlook I see the new tab, group and button included in the solution. But when I press the button I get the following error:

    An exception occurred while calling the function 'ButtonClick'. The exception message is:

     Thrown exception of type System.Runtime.InteropMessages.COMException with message "Retrieving the COM class factory for component with CLSID {00063052-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT 0x8004154 (REGDB_E_CLASSNOTREG))."

     

     

    Tuesday, January 17, 2012 11:54 AM

Answers

  • Does your button click handler get executed at all, or do you get that error when the handler is called, before any of the code there is called?
     
    That CLSID is for the ItemsClass, which isn't something that you normally would be accessing directly. Do you know where that comes from?
     
    Are all prerequisites, dependencies and references installed on the target computer?

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "ElreyBello" <=?utf-8?B?RWxyZXlCZWxsbw==?=> wrote in message news:6ad3c56c-b628-470a-813b-28c943cdef13...

    Hello,

    I created a Visual Studio 2010 Outlook 2010 Add-In with references to Interop.Excel and Interop.Outlook. Basically I have developed a new custom tab, with group and a button. In Button_OnClick I call a function from a Module. The code there creates a schema of the users appointments and attach the xl-sheet to an e-mail.

    When I hit F5 nothing happens in the Outlook that opens. I publish the solution and install it locally and when I open outlook I see the new tab, group and button included in the solution. But when I press the button I get the following error:

    An exception occurred while calling the function 'ButtonClick'. The exception message is:

     Thrown exception of type System.Runtime.InteropMessages.COMException with message "Retrieving the COM class factory for component with CLSID {00063052-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT 0x8004154 (REGDB_E_CLASSNOTREG))."

     

     


    Ken Slovak MVP - Outlook
    • Marked as answer by ElreyBello Tuesday, January 17, 2012 3:40 PM
    Tuesday, January 17, 2012 2:20 PM
  • The GUID corresponds to the Outlook.Items COM obejct.

    Are you trying to create an instance of that object (using new)? You cannot; it can only be retrieved from MAPIFolder.Items.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!
    • Marked as answer by ElreyBello Tuesday, January 17, 2012 3:40 PM
    Tuesday, January 17, 2012 3:15 PM
  • Restrcit returns Item colleciton, not Folder

    Items restrictedItem = olFolder.Items.Restrict

    By the way, do not use multiple dot notation - each call to olFolder.Items returns a brand new COM object:

    Items objItems = olFolder.Items)
    objItems.Sort("[Start]", False
    objItems.IncludeRecurrences = tru
    Items restrictedItems = objItems.Restrict("[Start] >= " & Quote(dtStart & " 12:00 AM") & " AND [End] < " & Quote(dtEnd & " 11:59 PM " ))


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!
    • Marked as answer by ElreyBello Wednesday, January 18, 2012 8:13 AM
    Wednesday, January 18, 2012 5:51 AM

All replies

  • Does your button click handler get executed at all, or do you get that error when the handler is called, before any of the code there is called?
     
    That CLSID is for the ItemsClass, which isn't something that you normally would be accessing directly. Do you know where that comes from?
     
    Are all prerequisites, dependencies and references installed on the target computer?

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "ElreyBello" <=?utf-8?B?RWxyZXlCZWxsbw==?=> wrote in message news:6ad3c56c-b628-470a-813b-28c943cdef13...

    Hello,

    I created a Visual Studio 2010 Outlook 2010 Add-In with references to Interop.Excel and Interop.Outlook. Basically I have developed a new custom tab, with group and a button. In Button_OnClick I call a function from a Module. The code there creates a schema of the users appointments and attach the xl-sheet to an e-mail.

    When I hit F5 nothing happens in the Outlook that opens. I publish the solution and install it locally and when I open outlook I see the new tab, group and button included in the solution. But when I press the button I get the following error:

    An exception occurred while calling the function 'ButtonClick'. The exception message is:

     Thrown exception of type System.Runtime.InteropMessages.COMException with message "Retrieving the COM class factory for component with CLSID {00063052-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT 0x8004154 (REGDB_E_CLASSNOTREG))."

     

     


    Ken Slovak MVP - Outlook
    • Marked as answer by ElreyBello Tuesday, January 17, 2012 3:40 PM
    Tuesday, January 17, 2012 2:20 PM
  • The GUID corresponds to the Outlook.Items COM obejct.

    Are you trying to create an instance of that object (using new)? You cannot; it can only be retrieved from MAPIFolder.Items.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!
    • Marked as answer by ElreyBello Tuesday, January 17, 2012 3:40 PM
    Tuesday, January 17, 2012 3:15 PM
  • I want to thank Ken & Dmitry in advance for their initial comments which solve the error I was getting.

    But now I get another error and I don't know if I'm suppose to continue on this thread.

    The error I get is the following:

    Error when retrieving appointments from calendar: Unable to cast COM object of type ''System._ComObject' to interface type 'Microsoft.Office.Interop.Outlook.Folder'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063006-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x8004002 (E_NOINTERFACE)).

    This is my code where the error is thrown:

     

    'Get calendar items.

     

    Dim olNamespace = olApplication.GetNamespace("MAPI"

    )

     

    Dim olFolder As Outlook.Folder = olNamespace.GetDefaultFolder(Outlook.OlDefaultFolders

    .olFolderCalendar)

     

    Try

     

    'Sort calendar items.

    olFolder.Items.Sort(

    "[Start]", False

    )

    olFolder.Items.IncludeRecurrences =

    True

    olFolder = olFolder.Items.Restrict(

    "[Start] >= " & Quote(dtStart & " 12:00 AM") & " AND [End] < " & Quote(dtEnd & " 11:59 PM "

    ))

    olItems = olFolder.Items

     

    Catch ex As

    Exception

     

    'Show error and return to exit application.

    MsgBox(

    String.Format("Error when retrieving appointments from calendar: {0}"

    , ex.Message))

     

    Finally


    ElreyBello
    Tuesday, January 17, 2012 3:40 PM
  • Restrcit returns Item colleciton, not Folder

    Items restrictedItem = olFolder.Items.Restrict

    By the way, do not use multiple dot notation - each call to olFolder.Items returns a brand new COM object:

    Items objItems = olFolder.Items)
    objItems.Sort("[Start]", False
    objItems.IncludeRecurrences = tru
    Items restrictedItems = objItems.Restrict("[Start] >= " & Quote(dtStart & " 12:00 AM") & " AND [End] < " & Quote(dtEnd & " 11:59 PM " ))


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!
    • Marked as answer by ElreyBello Wednesday, January 18, 2012 8:13 AM
    Wednesday, January 18, 2012 5:51 AM
  • Once again, thank you Dmitry for your help! If you only knew how many days I've spent trying to solve the errors thrown when I run my application. I'm new at Outlook Add-in development and all this is quite unfamiliar to me. I'm new at MSDN Forum too and I don't really know how it works when posting further questions regarding errors thrown later in the same application. But if its OK I got another error in the next function where I check that the appointments belong to the correct categories. What I do is to first add all the items from the olItems collection which are to be transfered to a temporary variable and then I want to replace the olItems with the temporary variable. I'm guessing the error is thrown at olItems = olTemp since intellisense is marking the line olTemp.Add(olItem) as 'used before assigned'. I don't know how to assign the variable and make the code work. The error message and the code is added below:

    Error:

    Unable to CAST COM object of type 'System._COMobject' to interface type 'Microsoft.Office.Interop.Outlook.Items'. This operation failed because the QueryInterface call on the COM component for the interface with IID {} failed because due to the following error: No such interface supported ().

    Code:

     

    'Get appointments with right category only.

     

    For Each olItem As Outlook.Items In

    olItems

     

      If olItem.Categories Is "External" Or olItem.Categories Is "Internal" Or olItem.Categories Is "Available"

    Then

        olTemp.Add(olItem)

     

      End

    If

     

    Next

     

    If olTemp.Count > 0

    Then

      olItems = olTemp

      blRetrieved =

    True

     

    Else

      olItems =

    Nothing

     

    End

    If


    ElreyBello
    Wednesday, January 18, 2012 8:29 AM
  • I solved the issue above by merging the two functions to the code below. But now I get another error:

    Object variable or With block variable not set.

    I think it is thrown at the if-statement, any ideas why?

    'Sort calendar items.

    olTemp = olFolder.Items

    olTemp.Sort(

    "[Start]", False

    )

    olTemp.IncludeRecurrences =

    True

    olItems = olTemp.Restrict(

    "[Start] >= " & Quote(dtStart & " 12:00 AM") & " AND [End] < " & Quote(dtEnd & " 11:59 PM "

    ))

     

    For i = 1 To

    olItems.Count

    count = 2

     

    If olItems.Item(i).Categories Is "External" Or olItems.Item(i).Categories Is "Internal" Or olItems.Item(i).Categories Is "Available"

    Then

    blRetrieved =

    True

     

    Else

    olItems.Remove(i)

     

    End

    If

     

    Next


    ElreyBello
    Wednesday, January 18, 2012 10:06 AM
  • Check for a value in or the existence of Categories before trying to use it. In managed code properties that would be returned as null string in VBA code are returned as null if they have no values in many cases. Attempting to access a value of a null property will fire an exception.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "ElreyBello" <=?utf-8?B?RWxyZXlCZWxsbw==?=> wrote in message news:481a2cba-7f1f-47b0-a6cb-4bbcde8177a0...

    I solved the issue above by merging the two functions to the code below. But now I get another error:

    Object variable or With block variable not set.

    I think it is thrown at the if-statement, any ideas why?

    'Sort calendar items.

    olTemp = olFolder.Items

    olTemp.Sort(

    "[Start]", False

    )

    olTemp.IncludeRecurrences =

    True

    olItems = olTemp.Restrict(

    "[Start] >= " & Quote(dtStart & " 12:00 AM") & " AND [End] < " & Quote(dtEnd & " 11:59 PM "

    ))

     

    For i = 1 To

    olItems.Count

    count = 2

     

    If olItems.Item(i).Categories Is "External" Or olItems.Item(i).Categories Is "Internal" Or olItems.Item(i).Categories Is "Available"

    Then

    blRetrieved =

    True

     

    Else

    olItems.Remove(i)

     

    End

    If

     

    Next


    ElreyBello

    Ken Slovak MVP - Outlook
    Wednesday, January 18, 2012 3:55 PM
  • Thank you for your reply. I will start another thread with an issue I got arrising from later sections of my code related to this topic. Thank you so far Ken and Dmitry!
    ElreyBello
    Thursday, January 19, 2012 9:43 AM