By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,084 Members | 1,266 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,084 IT Pros & Developers. It's quick & easy.

Retrieving information from AssemblyInfo.vb

P: n/a
What VB run-time methods are available to retrieve
information (such as AssemblyCopyright, AssemblyProduct,
AssemblyVersion, etc.) from the AssemblyInfo.vb file for
the current executable?

Thank you in advance for any help.
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
Hi AAguiar,

Thank you for using Microsoft Newsgroup Service. Based on your description.
You want to get the custom attributes info in the AssemblyInfo.vb file
generated by the VS.NET? If my understanding of your problem is correct,
here is my suggestion:

In dotnet, all such custom attributes are Assembly based. For example, when
you build and run your ASP.NET application, all the atrributes( such as
Copyright,Fileversion) are set as the Assemly Custom Attribute of the whole
Application Assemlbly. You can get such info mation of a dotnet Assembly
via the classes and methods under the "System.Reflection"

For example, here is a method to get the currently executing Assembly's
custom attributes: ( you can use it in a ASP.NET application)

Protected Sub GetAssemblyInfo()

Dim curAsm As System.Reflection.Assembly
Dim attrCompany As AssemblyCompanyAttribute
Dim attrConfiguration As AssemblyConfigurationAttribute
Dim attrCopyright As AssemblyCopyrightAttribute
Dim attrCulture As AssemblyCultureAttribute
Dim attrDescription As AssemblyDescriptionAttribute
Dim attrFileVersion As AssemblyFileVersionAttribute
'get the currently executing assembly instance
curAsm = System.Reflection.Assembly.GetExecutingAssembly()

'get the custom attributes in the assembly
Dim attrs() As Object
attrs =
curAsm.GetCustomAttributes(GetType(System.Reflecti on.AssemblyCompanyAttribut
e), False)
If attrs.Length > 0 Then
attrCompany = attrs(0)
Response.Write("<br>" + attrCompany.Company.ToString())
End If

attrs =
curAsm.GetCustomAttributes(GetType(System.Reflecti on.AssemblyConfigurationAt
tribute), False)
If attrs.Length > 0 Then
attrConfiguration = attrs(0)
Response.Write("<br>" +
End If

attrs =
curAsm.GetCustomAttributes(GetType(System.Reflecti on.AssemblyCopyrightAttrib
ute), False)
If attrs.Length > 0 Then
attrCopyright = attrs(0)
Response.Write("<br>" + attrCopyright.Copyright.ToString())
End If

attrs =
curAsm.GetCustomAttributes(GetType(System.Reflecti on.AssemblyCultureAttribut
e), False)
If attrs.Length > 0 Then
attrCulture = attrs(0)
Response.Write("<br>" + attrCulture.Culture.ToString())
End If

attrs =
curAsm.GetCustomAttributes(GetType(System.Reflecti on.AssemblyDescriptionAttr
ibute), False)
If attrs.Length > 0 Then
attrDescription = attrs(0)
Response.Write("<br>" + attrDescription.Description.ToString())
End If

attrs =
curAsm.GetCustomAttributes(GetType(System.Reflecti on.AssemblyFileVersionAttr
ibute), False)
If attrs.Length > 0 Then
attrFileVersion = attrs(0)
Response.Write("<br>" + attrFileVersion.Version.ToString())

End If

'attrFileVersion = (0)

End Sub

For more other infos about using dotnet reflecting to retrieve infomation
in a Assembly file, you can visit the following link on MSDN:
Please try out the preceding suggestions and let me know whether they help.

Steven Cheng
Microsoft Online Support

Get Secure!
(This posting is provided "AS IS", with no warranties, and confers no

Nov 18 '05 #2

P: n/a
Thanks Mr. Cheng.
That is exactly what I was looking for!

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.