AssemblyVersion attribute not visited

Apr 23, 2009 at 10:34 AM
Hi, I'm trying out the examples and in the PeToPe sample I notice that the MetadataMutator never visits the AssemblyVersion attribute, while, for example, visits the AssemblyFileVersion attribute.
What is the reason for that?
Coordinator
Apr 24, 2009 at 12:46 AM
The AssemblyVersion attribute is a "pseudo" attribute whereas the AssemblyFileVersion attribute is a "real" attribute. An attribute is "pseudo" if  "well behaved" compilers, such as the C# compiler, use the information in the attribute to set various metadata properties, but do not emit the attribute itself. ("Well behaved" is a matter of opinion, but the goodness here is that the compiler does not waste space in the assembly by storing the same information in two different formats.)

In the case of the AssemblyVersion attribute, the information shows up in the IAssemblyReference.AssemblyIdentity.Version property.

The CCI metadata model does not recreate the AssemblyVersion attribute for you, since that would either lead to duplication of the information, or to an IAssembly not being an IAssemblyReference, which would also be inconvenient.

In general, when the trade-off is not very clear, the CCI metadata model just tries to present a view of the world that is close to what you see in the CLR PE file format.
May 19, 2009 at 5:35 AM

hi hermanv

Can we  modify The AssemblyVersion or  Assembly Description?

if can ,how to do ?

thanks

 

Coordinator
May 19, 2009 at 5:38 AM

The metadata model produced by the PE reader is immutable. What you can do is to make a mutable copy and then change the mutable copy. The usual way to do so is via a derived class of the MetadataMutator class.

May 19, 2009 at 6:32 AM
Edited May 19, 2009 at 7:29 AM

hermanv ,thank you.

My task is modify the AssemblyVersion and save in Pe file .

I can get mutable copy  and change it ,How to write to Pe File?

thanks

Coordinator
May 19, 2009 at 2:25 PM

Use the PEWriter. The PeToPe example is a good starting point for seeing how everything hangs together.

May 19, 2009 at 3:09 PM

hi hermanv

Thank your apply.

I have read the PeToPe example before i commit this question. I can't find the interface of change module when i don't have document;

I will be very glad if you show some detail example ,for example add a method , change attribute value;

thank you 

Coordinator
May 21, 2009 at 4:39 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.