Question

We have several C# projects that use a legacy COM DLL via COM Interop.

In order to properly use some of the methods of the COM DLL we are forced to perform manual intermediate language (IL) modifications by first disassembling the DLL to IL, modifying it, and then re-assembling the DLL. This is a one-time process, i.e., the COM DLL does not change.

The following is a high level description of the steps performed:

  1. tlbimp - to create Interop*DLL using a strong name key (/keyfile parameter)
  2. ildasm - to generate the intermediate language (IL) from the Interop*DLL
  3. Manually change the methods/parameters in IL of interest
  4. ilasm - to reassemble the DLL (/dll parameter) using the same strong key (/key parameter) as in step 1.

The resulting DLL is then added as a reference to various C# projects. This DLL has no file version information associated with it, i.e., when using File Properties / Details tab.

We would like to be able to set the file version for the DLL. Any attempts to do so using external utilities or manual methods (from Windows Explorer / Properties / Details tab) makes the DLL fail the previously signed version of the file.

This is a plain file version that we are interested in, and has nothing to do with COM / Interop /etc. Ideally, the file version should be set in the process of re-assembling the DLL from IL using ilasm.

Thanks a lot!

Was it helpful?

Solution

ilasm utility has a /resource option that allows one to specify a resource with version info.

Here's an example of the new command that sets file version for the generated (re-assembled) DLL:

ilasm.exe Interop.filename.il /dll /key=snkey.snk /resource:Interop.filename.res

MSDN documentation for ilasm.exe can be found here:

http://msdn.microsoft.com/en-us/library/496e4ekx(v=vs.110).aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top