8

I have an .il file which I can compile without any problems. I can strong name it and so without any issues. But I am not able to set the file version via the attribute as I would expect it. How can I set the FileVersion for an assembly when using ilasm?

If I do a round trip I get always a .res file which does contain only binary data which is not readable. What is inside this res file and can I edit it?

The code does not work

.assembly myAssembly 
{
  .custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = { string('1.2.3.4') }
Alois Kraus
  • 13,229
  • 1
  • 38
  • 64

1 Answers1

13

The issue can be solved by using the .res file. It is not sufficient to do a round trip with ildasm and ilasm. The IL file does not reference the .res file. I had to add it to the ilasm call manually. The data in the res file seemed to contain the infos which are written into the PE header which is ok for me.

The final command line needed was

ilasm test.il /dll /res:test.res

I still do not know what exactly is inside the res file but I can exhange it with the meta data information of any other assemlby that I create manually and then decompile it to replace the metadata of the original assembly as I need.

It seems not many people are doing such stuff.

Alois Kraus
  • 13,229
  • 1
  • 38
  • 64
  • 1
    Every C/C++ programmer does this. Easiest way to create the .res file is with a dummy C++ project. You edit the .rc file, by hand or by using the resource editor in the C++ IDE. The rc.exe SDK tool translates it to .res – Hans Passant Feb 08 '12 at 14:10
  • Thanks I have not thought that VS can actually edit the Version resource in the binary editor. Its good to know that ilasm does not use some arcane binary format. – Alois Kraus Feb 08 '12 at 20:40