Calling Word method Application.ComAddins crashes after downgrading from Office 2013 to Office 2010

0

Some of our clients downgraded from Office 2013 to Office 2010.

After doing that if you call the Application property ComAddins you get the following exception:

System.Runtime.InteropServices.COMException (0x8002801D): Library not registered. (Excepción de HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))
   at Microsoft.Office.Interop.Word.ApplicationClass.get_COMAddIns()
   at our own code

We have tried to reinstall Office doing different cleanings to no avail. Any idea on what's wrong on the registry or how to fix it?

Can we find which registration is wrong and fix it somehow?

EDIT:

This is a sample that works on normal machines and fails on downgraded ones:

using System.IO;
using System.Runtime.InteropServices;
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Word;

namespace WordCorruptionTester
{
    public static class Program
    {
        public static void Main()
        {
            Application application = null;
            try
            {
                application = new Application();
                COMAddIns addins = application.COMAddIns;
                File.WriteAllText(@"c:\appAgn\office.txt", "OK");
                Marshal.ReleaseComObject(addins);
                Marshal.ReleaseComObject(application);
            }
            catch
            {
                File.WriteAllText(@"c:\appAgn\office.txt", "CORRUPTO");
                if (application != null)
                {
                    Marshal.ReleaseComObject(application);
                }
            }
        }
    }
}

CONTINUATION:

Following some really valid comments that's the new information gathered:

@Dirk Vollmar: Executing winword /r makes no difference.

@TnTinMn: long story short. Following your advice I found no issues but I saw that the file pointed by the interface was winword.olb so I re-registered it with "C:\Windows\Microsoft.NET\Framework\v4.0.30319>regtlibv12.exe "C:\Program Files (x86)\Microsoft Office\Office14\MSWORD.OLB"" as the error was about Library not registered. After doing this the error message changed to:

System.Runtime.InteropServices.COMException (0x80040155): Interface not registered (Excepción de HRESULT: 0x80040155)
   at Microsoft.Office.Interop.Word.ApplicationClass.get_COMAddIns()
   at our own code

Investigating a bit more I decompiled our own code that calls the get_COMAddIns and I found embedded the ID of the interface called: "000C0339-0000-0000-C000-000000000046"

enter image description here

c#
.net
ms-word
com
ms-office
asked on Stack Overflow Jan 26, 2018 by Ignacio Soler Garcia • edited Jan 29, 2018 by Ignacio Soler Garcia

1 Answer

0

I finally solved the issue this way (looks like an MS Office installer bug when downgrading from Office 2013 to Office 2010 that affects office automation):

"C:\Windows\Microsoft.NET\Framework\v4.0.30319>regtlibv12.exe "C:\Program Files (x86)\Microsoft Office\Office14\MSWORD.OLB""

"C:\Windows\Microsoft.NET\Framework\v4.0.30319>regtlibv12.exe "C:\Program Files (x86)\Common Files\Microsoft Shared\Office14\MSO.DLL""

This registrations leave the system working again.


User contributions licensed under CC BY-SA 3.0