How To: Read AssemblyInfo Attributes @ runtime

  • Thread starter Thread starter Jeff Ptak
  • Start date Start date
J

Jeff Ptak

Hey all,

Can anyone show me the proper C# syntax necessary to read
the attribute fields from the AssemblyInfo.cs file? I
have the following in VB.Net, but so far am unsuccessful
in translating the code to C#:

Dim objCopyright As AssemblyCopyrightAttribute = CType
(AssemblyCopyrightAttribute.GetCustomAttribute
(System.Reflection.Assembly.GetExecutingAssembly, GetType
(AssemblyCopyrightAttribute)), AssemblyCopyrightAttribute)

Dim objProduct As AssemblyProductAttribute = CType
(AssemblyProductAttribute.GetCustomAttribute
(System.Reflection.Assembly.GetExecutingAssembly, GetType
(AssemblyProductAttribute)), AssemblyProductAttribute)

Thanks!

J. Ptak
 
I know the Visual Basic syntax for this

it uses the

System.Diagnostics.FileVersionInfo Class

Dim verInfo as System.Diagnostics.FileVersionInfo
verInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(path as String)

then using the functions of verInfo you can get all information included in
the AssemblyInfo.vb File

Severin
 
Finally figured this out:

VB.NET Syntax:
Dim objCopyright As AssemblyCopyrightAttribute = CType
(AssemblyCopyrightAttribute.GetCustomAttribute
(System.Reflection.Assembly.GetExecutingAssembly, GetType
(AssemblyCopyrightAttribute)), AssemblyCopyrightAttribute)

C# Syntax:
AssemblyCopyrightAttribute objCopyright =
(AssemblyCopyrightAttribute)
AssemblyCopyrightAttribute.GetCustomAttribute
(System.Reflection.Assembly.GetExecutingAssembly(), typeof
(AssemblyCopyrightAttribute));

J. Ptak
 
Back
Top