3

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. Commented Oct 20, 2011 at 9:06
  • it's already in try-catch, control doesn't reach catch clause either - the application just terminates Commented Oct 20, 2011 at 9:27
  • I had such an issue earlier. I created the solution from scratch once more and then it worked fine. Commented Oct 20, 2011 at 9:47

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

9 Comments

Great Thanks. Very clear and accurate. Now I have registered ABCServert.dll using regsvr32. Now the COM tab for ADD REFERENCE dialog shows this ABCServer.DLL, so do i add a com reference or do i use same interop.abcserver.dll as a reference for my project? Please see edited question above.
Try to write Ilookup LP = New LoopUp();
The class name is actually LookUpClass, it would have given me a compile time error instead i guess :-)
the RCW lib should contain both LookUpClass and LookUp types.
Yes sir, Lookup is the contract/interface and Lookupclass is the implementation.
|
2

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.

1 Comment

Great Thanks. Very clear and accurate. Now I have registered ABCServert.dll using regsvr32. Now can i use same interop.abcserver.dll as a reference for my project? Please see edited question above.
0

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.

1 Comment

Great Thanks. Very clear and accurate. Now I have registered ABCServert.dll using regsvr32. Now can i use same interop.abcserver.dll as a reference for my project? Please see edited question above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.