views:

502

answers:

1

I've added a reference to a co-worker's COM DLL -- MyLogic.dll -- to my C# project in Visual Studio 2005. As expected, this auto-generates Interop.MyLogicLib.dll in my output folder. However, the version number of the COM DLL is 2.1.0.180, whereas the version number of the auto-generated interop assembly is 1.0.0.0. How do I get Visual Studio to preserve the original version number?

As it stands, the 1.0.0.0 version number is giving me grief in my product's installation. The installer refuses to overwrite earlier versions of the interop DLL because both old and new copies have the 1.0.0.0 version.

Incidentally, I've tried using "tlbimp /asmversion:2.1.0.180 MyLogic.dll" to manually generate the assembly at the command line, but:

  1. My project refuses to build with the manually-generated assembly, saying that the types I'm using are defined in an unreference assembly called Interop.MyLogicLib.dll (the one I'm making manually doesn't have the "Interop." prefix). Have to admit, I don't understand this.
  2. I need to know the version number in advance, instead of having a tool read it from the COM DLL
  3. It's a manual process, which sucks

Anyway, surely Visual Studio can automatically copy across the COM version number?

Update: Apologies; I appear to have duplicated another question. I did search for an existing one first, honest. I just missed it. :(

+2  A: 

The assembly version number is set by the type library version number, not the VERSIONINFO resource in the DLL. Be sure to set the "version" attribute for the library correctly in the IDL file:

import "oaidl.idl";
import "ocidl.idl";
[
  uuid(5F3D3EAC-0F66-4199-B548-654A9174552B),
  version(2.1),
  helpstring("Something descriptive here")
]

library YourLib {
  // etc
};
Hans Passant
Thanks. Given that the IDL can only specify the major and minor versions, I think I'll stick with manually generating the interop, as I need the finer version control.
Mal Ross