Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

COM Exception - TYPE_E_CANTLOADLIBRARY?

I am using a COM dll in my .Net web application. This works fine on multiple different machines.
However on one particular machine I get the following error:

Unable to cast COM object of type 'CServer.CApplicationClass' to interface type 'CServer.ICApplication'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{CF0DFA28-046B-4C7D-8AA9-F4B7477D8CAE} ' failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).

I have registerd the dll using the regsvr32 command.
I have also created a COM+ application for this dll. Running a search through the registry
I can find the key in numerous places. I have also tried unregistering the dll and deleting all referneces on the computer to this dll. And afterwards re-adding the dll and re-registering it.

I have written a simple windows script file which tests the dll. This works fine. However the problem exists in my .net project which is running in iis.

Can anyone help me with this?..

If you need anymore info please leave a comment. Thanks.

like image 723
shane87 Avatar asked Nov 05 '22 23:11

shane87


1 Answers

I had a similar problem, with the "TYPE_E_CANTLOADLIBRARY" message.

Background: I had a project which used Interop.ReferenceA.dll. This file was created using tlbimp ReferenceA.dll /out: Interop.ReferenceA.dll.

Solution: When I took a look at ReferenceA.dll using RegDllView I noticed that ReferenceA.dll had a subclass, which was the IID shown in the error message. I looked around in the source code of the subclass and noticed that it had a dependency to Interop.ReferenceB.dll.

Turns out that the subclass needed Interop.ReferenceB as a type-library to work. So I ran this:

regasm /tlb:Interop.ReferenceB.tlb Interop.ReferenceB.dll (the 32-bit version of regasm was used.)

And the error went away.

like image 146
01F0 Avatar answered Nov 13 '22 07:11

01F0