views:

171

answers:

1

I have a .Net 2 C# application I am developing which uses a VB 6 generated COM DLL. The VB DLL is updated frequently any my application crashes with a System.Runtime.InteropServices.COMException (0x80040154). The part of the COM DLL I use does not change but the version (and CLSID) will.

The "Specific Version" option for the reference is false. The WrapperTool is tlbimp.

How do I tell my application not to worry about changes in the DLL? Is there any way of checking just the functions I am using?

+2  A: 

It is one of the most common COM errors, "Class not registered". It starts at VB6, it has an option to control binary compatibility. I forgot exactly what that looks like, it's been too long. If you don't control this, VB6 is going to create a new COM server with different CLSID values. That requires re-registering the DLL with Regsvr32.exe. And re-generating the interop library with Tlbimp.exe. The latter step is probably the one you missed.

Note that using different CLSID values is a hard requirement for COM, it must be done when the public interface changes. But not when only the implementation changes.

Hans Passant
Thanks. The newer COM DLL has been registered. I have also found out that the CLSID has not changed.
John Hartley
The error tells a different story.
Hans Passant
Sorry Mr Bugz. I missed a step I always miss, the Tlbimp.exe step. The IDE (SharpDevelop) must invoke it when compiling.
John Hartley
tlbimp.exe does not exist on the compiling machine. I wonder what magic SharpDevelop is using to generate the interop DLL...
John Hartley