views:

1373

answers:

3

I had a C# program that did some Word & Excel automation and it used Office 2003 Primary Interop Assemblies. The way I deployed it was by including the Interops in the bin and I had my program reference it from there as opposed to referencing it from the GAC (not very professional, but it worked fpr years). Recently on 3 machines the office 2007 compatibility pack was installed and now when ever my software trys to invoke Word or excell I get an error that:

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 the interface with IID {00020970-0000-0000-C000-000000000046} failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))

After some searching I noticed that installing the compatibity pack Word11 and Word12 were both installed in the GAC and the same with Excel.

I attempted to have my program reference the Word11 interop in the GAC and still no help. I unstalled the Word12 interop and still no help. It seems that installing this seemed to have changed some registry setting or something that my software is confused cannot find the correct library.

Anybody have some ideas?

A: 

I've worked around this by copying the earlier versions from the GAC to our Third Party libraries folder, and reference them there -- also means you can build against 2003 with only 2007 installed. (and yes, I know this is a really dirty hack)

Rowland Shaw
It didn't work, even if I reference my local PIA it still throws the same error
A: 

I recently had this issue with word too and I tracked down this registry key as the culprit

HKEY_Classes_Root\TypeLib\{00020905-0000-c000-000000000046}\8.4

Apparently this tells the word to use word 2007 introp assemblies instead of Word 2003 (8.3). At least I think I am not too familiar with office introp assemblies. I delete the registry key and everything worked as normal. I do not know of any adverse effects from deleting this key, but definitely back it up.

Christopher Bright