VSTO Outlook Addin with Exception System.Runtime.InteropServices.COMException (0x80040154)

0

System.Runtime.InteropServices.COMException (0x80040154): Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

I am developing a VSTO Outlook addin which only counts the items for a mailbox. It is working fine on a lot of PC, but I got this exception from one Window 10 PC that running lastest version 17134.191 and Outlook 32bit. I don't have any dependencies on any COM DLL and I have tried to make release that target x86 specifilly. My addin could start on this problem PC, the exception occur in this simple method making count.

'code is here

private int GetItemsCount(MAPIFolder folder, int count)

    {

        try
        {

            count = count + folder.Items.Count;

            //contains subfolders
            if (folder.Folders.Count > 0)
            {
                foreach (MAPIFolder fd in folder.Folders)
                {
                    count = GetItemsCount(fd, count);
                }
            }
        }
        catch (System.Exception ex)
        {
            //log
            if (DebugSetting.Debugger)
            {
                Logger.PrepareBlock("Get Item Count Fails, Top Level Exception: " + ex.ToString());
                Logger.Write();
            }
        }

        return count;
    }'

I can see in the log, there are 3 exceptions and then follows a count number, then comes the same exception again.

com
asked on Stack Overflow Aug 9, 2018 by Benzhi Pan

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0