3
votes

Scenario - I am writing a console application. Need to use a certain DLL called Interop.ABCServer.DLL [I'm new to COM, so really don't know where it comes into picture here, but i have checked this DLL through ILDASM, it opens and shows metadata. So, i guess it's a .NET DLL and not a COM DLL]

Now when i try to use it by initiating certain class from it, it gives me an exception - Retrieving the COM class factory for component with CLSID<1111-1111....> failed due to following error:80040154.

Questions - supposing COM component is an old technology and requires component to be registered first, we need to register it somehow. How do i register this component (remembering it's a .NET dll and not a COM dll)?

Is above registration the resolution of the problem? IF not, then how to resolve it.

Now i have registered ABCServer.dll using regsvr32.dll. But,

I have code like,

try
{
    Ilookup LP = New LoopUpClass();
    IServer Svr = LP.LookUpServer(hostname, port);
}
catch(Exception ex)
{

}

Line 1 that was giving error previously now just terminates the application. I'hv even added break points on line 1 and line 2 while debugging. But control never reaches line 2, application just terminates as soon as i press F10 while on line 1.

Basically, once i have registered the COM, how do i use it. Do i need to register it from COM tab in ADD REFERENCE dialog, OR do i need to create a INTEROP.ABCServer.DLL afresh OR can i use the original INTEROP.ABCServer.DLL that i was provided.

3
Put try{..}Catch(Exception ex){...} and see if you get to the exception.Kangkan
it's already in try-catch, control doesn't reach catch clause either - the application just terminatesEagerToLearn
I had such an issue earlier. I created the solution from scratch once more and then it worked fine.Kangkan

3 Answers

2
votes

Your Interop.ABCServer.DLL seems to be just the runtime callable wrapper. It contains just code that marshalls calls to the real COM library.

So you need a second dll which is your concrete COM component which you have to register with regsvr32.exe. Its probable called ABCServer.DLL

To your appended questions:

If the provided Interop lib is up to date you can use it. If not, you can create your own with TLBIMP.EXE. When adding a referecne to the COM dll directly, CS will generate the RCW lib on the fly for you. Thats absolutely ok, if you don't have dependencies between multiple COM libaries you want to use.

2
votes

The 80040154 is normally an error due to that a COM component hasn't been registered. You typically register a COM dll using regsvr32 yourdll.dll, this will add the GUIDs to your registry so that whenever the GUID for the COM object is used, the system will know where to load the DLL from.

.NET creates a wrapper for COM dlls and that is this Interop.*.* that you see however you need to register the DLL that the wrapper is for. Probably you have a ABCServer.DLL somewhere.

0
votes

Interop.ABCServer.dll probably references some other dll containing COM Code. Check in the assembly manifest which are they. To register a COM component, use regsvr32.

If you want to check that a component is wel registered, check in the registry under HKEY_CLASSES_ROOT that your component is well listed. Based on the CLSID, you can look under HKEY_CLASSES_ROOT\CLSID to figure out the path to the dll.