How To: Read AssemblyInfo Attributes @ runtime

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
 
S

sampsons

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
 
J

Jeff Ptak

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top