.net - How can tlbimp be used to specify different File and Assembly versions? -


We are using tlbimp to generate interop assemblies. We want to print the interop assembly with both a file version and assembly version. However, both the / asmversion option on tlbimp is being set as the same value.

Does anyone know how to set up separate file and assembly versions on an interop assembly using tlbimp? Finally we found some links on a code named tlbimp2 at codeplex, and our own revised version Tlbimp2 compiled:

  • I took the code from the tlbimp project of 2. And it modified on the lines of 1. There were some problems that we had to work around:

    In TlbImp.cs, I was clearly to collect file version number from the result of FileVersionInfo.GetVersionInfo, because the FileVersion property was empty:

      if (options.m_strFileVersion == faucet) {// Get File Version Version Version INFO = FileVersionInfo.GetVersionInfo (options.m_strTypeLibName); the option. M_strFileVersion = versionInfo.FileMajorPart + "." + Version INFO.FileMinorPart + "." + Version INFO.FileBuildPart + "." + Version INFO.FilePrivatePart; }   

    I had to switch to tlbimpcode.cs:

      asmBldr.DefineVersionInfoResource (strProduct, strProductVersion, strCompany, strCopyright, strTrademark);   

    From:

      asmBldr.DefineVersionInfoResource ();   

    or custom resources will not be used.

    Hope this helps with someone else with the same problem.

  • Comments