VB: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)

First of all, try to run Visual Studio with the /ResetUserData command line argument. Read more about that in the Error “Unable to cast COM object…” when exporting to Microsoft Excel from Team Explorer 2008 article.

Obviously you are trying to connect to a wrong Excel version. Looks like you have some extra windows registry keys left after uninstalling an old version of Office or vice versa. Anyway, take a look at the How to solve “Unable to cast COM object of type Microsoft.Office.Interop.Excel.ApplicationClass’ to interface type ‘Microsoft.Office.Interop.Excel._Application’” blog post which describes exactly the same issue. Basically you need to find a wrong entry in the windows registry and then delete it.

BTW When you add a new COM reference to the project a missed PIA is generated automatically (if it doesn’t exist any longer). So, that is a possible way to go. Also you may try to embed interop types into your own assembly like the following screenshot shows:

Leave a Comment