How can I access AssemblyVersionAttribute in AssemblyInfo.cpp

  • Thread starter Thread starter Eddie
  • Start date Start date
E

Eddie

I tried a few more thing.

I found that I can access the AssemblyInfo.cpp like follows.(This is
from the VS help system.)

Type^ clsType = Form1::typeid;
Assembly^ assy = clsType->Assembly;

AssemblyProductAttribute^ apAttr =
dynamic_cast<AssemblyProductAttribute^>(Attribute::GetCustomAttribute(assy,

AssemblyProductAttribute::typeid));

AssemblyVersionAttribute^ avAttr =
dynamic_cast<AssemblyVersionAttribute^>(Attribute::GetCustomAttribute(assy,

AssemblyVersionAttribute::typeid));

MessageBox::Show(apAttr->Product + L" " + avAttr->Version);

This code works well with AssemblyProductCode, ... and all only except
AssemblyVersionAttribute.
avAttr always gets nothing.

Do you have any idea on this?
I spend a lot of time for this meaningless thing. ;-(
 
Eddie said:
This code works well with AssemblyProductCode, ... and all only except
AssemblyVersionAttribute.
avAttr always gets nothing.
AssemblyVersionAttribute is a pseudo custom attribute (well,
strictly speaking, it is not exactly but I behaves like one)

When emitted to the metadata representation, they are
not emitted as custom attributes but are rather translated to
specialized constructions.

To access the information use the special APIs. For
AssemblyVersion use assy->GetName()->Version.

-hg
 
Back
Top