Using reflection to get more out of your AssemblyInfo.vb file

This is part 2 of my post on “ASP.Net Page titles ”

With System.Reflection.Assembly.GetExecutingAssembly
ProdTitleLbl.Text = CType(.GetCustomAttributes(GetType(AssemblyTitleAttribute), False)(0), AssemblyTitleAttribute).Title
ProdCoLbl.Text = CType(.GetCustomAttributes(GetType(AssemblyCompanyAttribute), False)(0), AssemblyCompanyAttribute).Company
ProdDescLbl.Text = CType(.GetCustomAttributes(GetType(AssemblyDescriptionAttribute), False)(0), AssemblyDescriptionAttribute).Description
ProdTMLbl.Text = CType(.GetCustomAttributes(GetType(AssemblyTrademarkAttribute), False)(0), AssemblyTrademarkAttribute).Trademark
ProdCrLbl.Text = CType(.GetCustomAttributes(GetType(AssemblyCopyrightAttribute), False)(0), AssemblyCopyrightAttribute).Copyright
ProdVersLbl.Text = .GetName().Version.ToString
End With

By using this you treat your assembly page as a constants page and reduce the maintainance of your code.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.