Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AssemblyVersionAttribute returns String::Empty

Status
Not open for further replies.
Jan 20, 2005
65
GB
Why does the AssemblyTitleAttribute and AssemblyCopyrightAttribute return the correct values but AssemblyVersionAttribute always returns an empty string?

I've specified the version in the assembly!

Code:
Assembly^ assy;

try
{
  assy = Assembly::LoadFile(gcnew String(lpFilename)); 
}
catch( Exception ^ e)
{
  MessageBox::Show(e->Message);
}

InitializeComponent();

// Iterate through the attributes for the assembly.

System::Collections::IEnumerator^ myEnum = Attribute::GetCustomAttributes( assy )->GetEnumerator();

while( myEnum->MoveNext())
{
  Attribute^ attr = safe_cast<Attribute^>(myEnum->Current);
  // Check for the AssemblyTitle attribute.
  if(attr->GetType() == AssemblyTitleAttribute::typeid)
  lblAppName->Text = dynamic_cast<AssemblyTitleAttribute^>  (attr)->Title;

// Check for the AssemblyVersionAttribute attribute.

else

// Check for the AssemblyVersionAttribute attribute.

if(attr->GetType() == AssemblyVersionAttribute::typeid)

lblAppVersion->Text = dynamic_cast<AssemblyVersionAttribute^>(attr)->Version;

// Check for the AssemblyCompany attribute.

else

// Check for the AssemblyCopyright attribute.

if(attr->GetType() == AssemblyCopyrightAttribute::typeid)

lblAppCopyright->Text = dynamic_cast<AssemblyCopyrightAttribute^>(attr)->Copyright;

}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top