Search code examples
comversionmanifest

Where the interop version is coming from when using TlbImp


I'm using tlbimp to generate a .Net interop of a COM assembly. This COM assembly has a product version and file version like 7.X.X.X but when I'm using TlbImp, my interop has then a version like 1.Y.0.0. I'm aware I can change this version when I'm using TLBImp via parameters of the executed command lines but I'm wondering where this version comes from. Can I access a manifest of this COM assembly? Why I cannot see this version on the property of the file in the explorer?

I have different version of this assembly and I see the version generated always different but I'm failing to find where this version come from.

Thanks


Solution

  • I had a hunch that it was the version of the typelib. I took a test project that had a typelib of version 1.0 and ran tlbimp on it, and it produced an import assembly with file version of 1.0. I then changed the version of the typelib to 1.19, recompiled, and reran tlbimp. The file version of the new import assembly was 1.19 (well, 1.19.0.0).

    Using OleView you can load the typelib of the EXE/DLL your using for tlbimp. Check the version of the typelibrary. Compare it to the file version of your import assembly. I bet they match.

    Makes sense they'd want the version numbers to match.