COM Exception - TYPE_E_CANTLOADLIBRARY?

4

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.

asp.net
exception
com
registry
asked on Stack Overflow Apr 18, 2011 by shane87

4 Answers

2

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.

answered on Stack Overflow Jul 8, 2014 by 01F0 • edited Jul 8, 2014 by 01F0
0

Make sure your AppPool is set to x86. Also make sure your assembly is targeting only x86.

answered on Stack Overflow Apr 18, 2011 by Daniel A. White • edited Apr 18, 2011 by Daniel A. White
0

I was having a similar issue. First got Access Denied, which after some looking around was resolved, only to be faced with this error message (TYPE_E_CANTLOADLIBRARY). Mind that I'm running a COM+ Component on Windows 7.

After some fruitless attempts which involved messing with the registry, my workmate and I found a way of getting it up and running:

1) Unregister your dll (regsvr32 -u dllname)

2) make sure your references to the dll are cleared up from registry (backup first)

3) Create an empty com+ application (server app) in Component Services

4) Copy the application id to the clipboard

5) go to "c:\program files (x86)\Complus applications" and create a folder with the id on your clipboard

6) copy your dll into that folder and register it

7) Go back to your Component Services and add the component to the app you created using the dll on "c:\program files (x86)\Complus applications{*app id*}"

that did it for me. Hope it helps.

answered on Stack Overflow Dec 10, 2013 by Ricardo Appleton
0

I had a similar problem where the error was triggered on my PC but not on that of other developers.

It turns out that I had been testing an automatic build process on my PC that had updated the version number of the assembly, thus registering the TLB in the registry with a version number higher than the one we were normally using.

When trying to get the interface, the server was consistently using the wrong TLB information leading to the wrong assembly. Once I deleted the higher version entry in the registry, it worked fine.

Now we just have to ensure the build process is not going to cause that issue again. :)

answered on Stack Overflow Jan 14, 2020 by Philippe Lignon

User contributions licensed under CC BY-SA 3.0