How To: Read AssemblyInfo Attributes @ runtime

Discussion in 'ASP .Net' started by Jeff Ptak, Jul 14, 2003.

  1. Jeff Ptak

    Jeff Ptak Guest

    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
    Jeff Ptak, Jul 14, 2003
    #1
    1. Advertising

  2. Jeff Ptak

    sampsons Guest

    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

    "Jeff Ptak" <> wrote in message
    news:065a01c34a1f$7cb9f870$...
    > 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
    >
    sampsons, Jul 14, 2003
    #2
    1. Advertising

  3. Jeff Ptak

    Jeff Ptak Guest

    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

    >-----Original Message-----
    >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
    >
    >.
    >
    Jeff Ptak, Jul 14, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. C

    AssemblyInfo

    C, Nov 28, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    460
    Tommy
    Nov 28, 2003
  2. Rob
    Replies:
    2
    Views:
    4,367
  3. Bob
    Replies:
    0
    Views:
    1,589
  4. =?Utf-8?B?Q2hyaXMgRmluaw==?=

    AssemblyInfo version display on WebPage

    =?Utf-8?B?Q2hyaXMgRmluaw==?=, Oct 8, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,541
    =?Utf-8?B?S2VuIENveCBbTWljcm9zb2Z0IE1WUF0=?=
    Oct 8, 2004
  5. =?Utf-8?B?TWFya0F1cml0?=

    assemblyinfo version

    =?Utf-8?B?TWFya0F1cml0?=, Jan 11, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    1,125
    Curt_C [MVP]
    Jan 11, 2005
Loading...

Share This Page