locked
0x80029C4A (TYPE_E_CANTLOADLIBRARY) RRS feed

  • Question

  • After installing my application (the installation log looks fine), a particular client (US Military) received the following error when trying to start my application:

     

    System.InvalidCastException: Unable to cast COM object of type 'Microsoft.Office.Interop.Word.ApplicationClass' to interface type 'Microsoft.Office.Interop.Word._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00020970-0000-0000-C000-000000000046}' failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).

     

    Based on other responses I have read on this error, it looks like the registry may be corrupted by Anti-virus script blocking software or by multiple instances of Office installed.  Indeed the client is running the Symantec software. Are there other causes I should be aware of?

     

    Is there something my code can do to get around this?  I don’t want to have them reinstall Office, as to them it is working fine (i.e. they can start Word and Outlook manually just fine).

     

    Tuesday, August 14, 2007 4:37 PM

Answers

  • Hi Guys!

    I've been struggling with a similar problem for about 3 days solid now, and finally after an intense amount of googling and lots of trial and error, I have managed to solve it, I hope the same solution can be applied to your problems.

    First off, some basic background info. This problem arose for me after uninstalling Office 2007 and going back to Office 2003 due to the Office 2007 PIA's not being able to communicate correctly and provide backwards compatibility with Office 2003. Upon reinstallation none of my COM calls to any Office COM DLL would work, every call would return the error that is mentioned in the post i.e. CANTLOADLIBRARY, with a long CLSID number e.g. {A5EDEDF4-2BBC-45F3-822B-E60C278A1A79}. I deduced that this must have been due to Office 2007 leaving a bad trail of uninstalled registry key entries...

    This CLSID is the key to solving the problem.

    First off copy the CLSID from the error window that appears in VB.NET. Access the registry via Start, Run, Cmd, RegEdt32, enter. Once the registry editor loads up, do a search (ctrl F3) on that specific CLSID (I didn't include the braces, but it shouldn't matter). The registry should find a key located under the HKEY_CLASSES_ROOT -> CLSID subkey. Expand this key and you should see 3 nodes: ProxyStubCLSID,ProxyStubCLSID32 and the important one - TypeLib. Essentially what is happening is that when you make the COM call to a specific Office assembly. The assembly opens up the registry and finds this key which gives it the CLSID of the TypeLib it must call in order to initiate a call to the COM.

    Under the TypeLib key copy the (Default) Entry (It should be another long CSLID key). Now the easiest way to find this new key entry relating to the CLSID, is to go back up to the root key, HKEY_CLASSES_ROOT and look for the TypeLib subkey. I did this by simply pushing "T" on the keyboard till I got to the all the "T's" on the level below the HKEY root. Once you find this key, highlight the key and do a search (Ctrl F3) from this key for the TypeLib CLSID that you copied earlier. Once you find it, expand it and see if there are multiple versions of the typelib i.e. 8.3, 8.4, 8.5. You want to eliminate the the later versions that are pointing to non-existant TypeLib's. To do this, expand the Version key (ie. 8.3), then expand the "0" key, then the win32 key and check the value of the default entry. This value should be a file path. Mine was pointing to a tlb file in an Office12 directory (Office 2007), that obviously didn't exist since I uninstalled 2007. Simply delete this key, and now when the COM interface attempts to locate the latest TypeLib it will find one that does indeed exist, and will hopefully run error free. Well at least it did for me.

    Hope this solves some of your guys problems.

    Cheers!
    Thursday, January 10, 2008 7:52 AM

All replies

  • I have almost the same question

     

    i have a word 2003 macro for the new employee for my compagny. I build an interface for the Human ressources but i can acces my macro.

     

    Unable to cast COM object of type 'Microsoft.Office.Interop.Word.ApplicationClass' to interface type 'Microsoft.Office.Interop.Word._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00020970-0000-0000-C000-000000000046}' failed due to the following error: Cette interface n'est pas prise en charge (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

     

    somebody help me please

     

    ps i'm french canadian so excuse my english

     

    thanks

    Thursday, August 16, 2007 7:59 PM
  • Hi, did you find any solution for that? I have the same problem, on some machines it runs, on some it doesn't (same model series, same software) and I get the same error message. I did not find anything to solve it.

     

    If anyone found a solution I would be very pleased to know.

     

    Thanks.

     

    Monday, November 26, 2007 3:43 PM
  • This I think is the need for you to install the Microsoft PIA's for the version of office you are trying to work with. This is for Office 2003 PIA's. it is very important to then re-reference the Office projects to update to use the PIA libraries. http://www.microsoft.com/downloads/details.aspx?familyid=3c9a983a-ac14-4125-8ba0-d36d67e0f4ad&displaylang=en

     

    Regards

     

     

     

    Monday, November 26, 2007 9:18 PM
  • I have the same question but re-install the PIA's does not solve it. What to do next?

    Monday, December 31, 2007 2:42 AM
  • Hi Guys!

    I've been struggling with a similar problem for about 3 days solid now, and finally after an intense amount of googling and lots of trial and error, I have managed to solve it, I hope the same solution can be applied to your problems.

    First off, some basic background info. This problem arose for me after uninstalling Office 2007 and going back to Office 2003 due to the Office 2007 PIA's not being able to communicate correctly and provide backwards compatibility with Office 2003. Upon reinstallation none of my COM calls to any Office COM DLL would work, every call would return the error that is mentioned in the post i.e. CANTLOADLIBRARY, with a long CLSID number e.g. {A5EDEDF4-2BBC-45F3-822B-E60C278A1A79}. I deduced that this must have been due to Office 2007 leaving a bad trail of uninstalled registry key entries...

    This CLSID is the key to solving the problem.

    First off copy the CLSID from the error window that appears in VB.NET. Access the registry via Start, Run, Cmd, RegEdt32, enter. Once the registry editor loads up, do a search (ctrl F3) on that specific CLSID (I didn't include the braces, but it shouldn't matter). The registry should find a key located under the HKEY_CLASSES_ROOT -> CLSID subkey. Expand this key and you should see 3 nodes: ProxyStubCLSID,ProxyStubCLSID32 and the important one - TypeLib. Essentially what is happening is that when you make the COM call to a specific Office assembly. The assembly opens up the registry and finds this key which gives it the CLSID of the TypeLib it must call in order to initiate a call to the COM.

    Under the TypeLib key copy the (Default) Entry (It should be another long CSLID key). Now the easiest way to find this new key entry relating to the CLSID, is to go back up to the root key, HKEY_CLASSES_ROOT and look for the TypeLib subkey. I did this by simply pushing "T" on the keyboard till I got to the all the "T's" on the level below the HKEY root. Once you find this key, highlight the key and do a search (Ctrl F3) from this key for the TypeLib CLSID that you copied earlier. Once you find it, expand it and see if there are multiple versions of the typelib i.e. 8.3, 8.4, 8.5. You want to eliminate the the later versions that are pointing to non-existant TypeLib's. To do this, expand the Version key (ie. 8.3), then expand the "0" key, then the win32 key and check the value of the default entry. This value should be a file path. Mine was pointing to a tlb file in an Office12 directory (Office 2007), that obviously didn't exist since I uninstalled 2007. Simply delete this key, and now when the COM interface attempts to locate the latest TypeLib it will find one that does indeed exist, and will hopefully run error free. Well at least it did for me.

    Hope this solves some of your guys problems.

    Cheers!
    Thursday, January 10, 2008 7:52 AM
  •  

    So long...

    I have solved this problem too...

    Actually, all you have to do is reinstalling Office 2003...

    By the way, if  you use Vista,  you should install the Office 2003 SP3 or you will not get the right result.

     

    Hope all guys solve the problems !

    Thursday, January 10, 2008 2:11 PM
  • "Hope this solves some of your guys problems."

    Well, it did!

    Perfectly!

    Thanks!
    Friday, May 9, 2008 10:08 AM
  • I got the same problem and here's what I did (In case someone has the same issue).

    In fact, I had Office 2003 and 2007 installed on my PC, and I was getting some SEHException when running a "Find". I then uninstalled Office 2007 which didn't solve the problem. Then, I completely removed 2003. After that, I reinstalled 2003. Here, I got this error when running the code again.

    So, from there, I got to this post and looked in the regedit for any 2007 traces. This is where I got confused since I couldn't find anything about 2007. However, I didn't reboot the PC since the last 2003 installation, so I assumed that the DLLs were not completely registered. I did, but it didn't solve anything.

    I felt I was out of luck. So, in desperation to find something I did an installation repair on Office 2003 and it worked!

    Everything works perfectly now! Still need to find a way to have this to work with 2007 though...
    Thursday, July 17, 2008 1:18 PM
  • Thanks for posting this fix.

     

    I had the same problem loading an Outlook 2003 add-in after Office 2007 was uninstalled.

     

    The version numbers were 2.1 etc. and the last one referred to Office V12. I deleted the reference and the problem disappeared.

     

    Many thanks!

     

    Friday, September 5, 2008 5:47 PM
  • Dear CyberAnt, a big, BIG, HUUUUGE "thank you!" for your solution! I was banging my head on the desk since a few days about this, and now it's finally solved!!!
    Gianluigi Zanettini - http://www.megalab.it
    Tuesday, October 27, 2009 9:15 AM
  • Thank you to CyberAnt for a solution that was easy to follow.
    Thursday, February 18, 2010 1:07 PM
  • Just the repair install of Office worked for me. Thanks guys.
    If you buy three cars and the same wheel falls off all three, do you contact the person who sold you the cars or the person who made them?
    Wednesday, May 5, 2010 12:51 AM
  • Hi

     

    I have tried your method but didn't find the solution as i have the following data in the TypeLib

    Version 9.3

    Value -C:\Program Files\Microsoft Office\Office12\msoutl.olb and the file exists in my path.

     

    I have been worked for this error.

    Unable to cast COM object of type 'System.__ComObject' to interface type

    'Microsoft.Office.Interop.Outlook.PostItem'. This operation failed because the

    QueryInterface call on the COM component for the interface with IID

    '{00063024-0000-0000-C000-000000000046}' failed due to the following error: No such

    interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

     

    Please if you have anymore idea ,please let me know.

     

    Thanks

    Thursday, September 23, 2010 1:53 PM
  • thanks so much for your help and your clear explaination! It works perfectly! 

    Just one little variation...I've deleted the whole key-folder 8.4 and it started to work! :)

    Saturday, October 30, 2010 8:20 PM
  • Just ran into this as well- for some dev work I needed to downgrade from office 2010 x64 to office 2010 x86.  I followed the registry search described by CyberAnt (thanks BTW!) but didn't see any additional versions- just a win64 and win32 folder under a single 1.0 version folder.

    I nuked the entire directory matching the default key from the original CLSID.  Ran office 2010 x86 repair, and all good again.

    Tuesday, April 12, 2011 8:59 PM
  • This same issue occurs when your office 2010 trial times out and refuses to uninstall.  Thanks CyberAnt. 

    Thursday, October 6, 2011 2:04 PM
  • Perfect shot!

    I had exact same problem for past 2 days and by following your comments I found out that I have 8.3 (2003 office) valid path and no path at all under 8.4 version (empty keys and values). After I delete this orphand subkey my code worked!

    thanks...

     

    • Proposed as answer by Papy Normand Wednesday, August 29, 2012 8:13 PM
    Thursday, November 10, 2011 10:55 AM
  • I had the same problem removing office preview on my Win8/RTM machine.. and got stuck using 2010. For me I deleted 8.6 directory... run my application and it worked !

    Thanks for this post !


    Frederic (MSFT)

    Thursday, August 23, 2012 1:10 PM
  • CyberAnt, thank you!  This brilliant fix worked perfectly. 
    Thursday, October 11, 2012 7:06 PM
  • I was having similar issues with a home-grown app after uninstalling an Office 365 trial and going back to Office 2007 and your solution fixed our problem. Many thanks.
    Wednesday, April 10, 2013 3:09 PM
  • Its really Great. 

    I was having an issue with SharePoint 2013 Search Service and I have solved using this article. 

    Its really great 

    Thanks again

    Sunday, February 15, 2015 10:48 AM
  • Brilliant! This helped me fix a problem with ACT!2013 after installation and removal of Office 2013. There was an 8.6 key that when removed allowed the mail merge to work :)

    Andrew

    Monday, February 23, 2015 4:12 PM
  • You are a genius!
    Thursday, April 7, 2016 6:19 AM
  • I use what you did to solve my issue. In my case, I was interacting with CaseWare Working Papers. Although my CSLID and TypeLib is different than described in your step. 

    Thank you. 

    Wednesday, April 20, 2016 6:14 PM
  • Unfortunately i've read your post too late, when i've already repaired office and fixed the problem :)
    Thursday, May 5, 2016 10:54 AM
  • Great finding for me in a legacy code in 2018 :)

    Thanks for the great explanation.

    • Edited by Volem Tuesday, May 29, 2018 2:07 PM
    Tuesday, May 29, 2018 2:07 PM
  • I had this issue  with another scenario

    We moved from office 2013 to office 365 

    and some vs2013 projects that exports to Excel began to fail

    I had to check in REGEDIT with this instructions

    and I finally Resolved this problema

    thanks so much for this information

    Wednesday, December 19, 2018 7:16 PM
  • Thank you! Couldn't solve this one for quite a while, and thanks to your steps my app is now working again.
    Tuesday, February 5, 2019 11:18 AM
  • Just Add

    using Excel = Microsoft.Office.Interop.Excel;

    Monday, February 18, 2019 12:52 PM
  • Unbelivable how much i likes this old posts, helped like a magic, Thanks.
    Tuesday, April 7, 2020 6:08 AM
  • 12 years since this post and you're still helping people!  Thanks!  Fixed my issue I was struggling with!
    Tuesday, September 22, 2020 7:50 PM