When I add a COM reference to a project VS shows the Name and Version. The displayed version is two terms (i.e. it takes the form X.X).

However, when I try to get the version number (via FileVersionInfo) I get a number in the format X.X.X.X and it doesn't always correlate to the number shown in the add references dialog.

How can I extract this number from a DLL file?

有帮助吗?

解决方案

The X.X version number is the type library version number, encoded as major.minor. It is embedded in the type library, a .tlb file or embedded as a resource in a DLL. You can see it with the OleView.exe utility, View + Typelib command. It also appears the registry which is how Visual Studio finds them, HKCR\Typelib key.

The X.X.X.X version number is the file version number, embedded as a resource in the executable file. It normally encodes major.minor.build.revision numbers. Not a requirement, it can be any string. In .NET you specify it with the [AssemblyFileVersion] attribute. You can see it with Visual Studio's File + Open + File command, select the DLL or EXE and double-click the Version.1 resource (not available in Express).

The type library version number represents the version of the public interface for the COM server. It doesn't change often since changes are pretty painful to client code. The file version number represents the serial number of the file when it was built. It changes very often. The numbers don't often have anything in common.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top