How To: Read AssemblyInfo Attributes @ runtime

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default How To: Read AssemblyInfo Attributes @ runtime

    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 Guest

  2. Similar Questions and Discussions

    1. #39467 [Opn]: Expaned Class members to allow setting of a read only value at runtime
      ID: 39467 User updated by: kevin at metalaxe dot com Reported By: kevin at metalaxe dot com Status: Open Bug Type: ...
    2. #39467 [NEW]: Expaned Class members to allow setting of a read only value at runtime
      From: kevin at metalaxe dot com Operating system: * PHP version: 5.2.0 PHP Bug Type: Feature/Change Request Bug description:...
    3. Changing CFINPUT attributes at RUNTIME
      Hello All, I just figured out how to change the enabled feature of a text field in CFFORM based on a radio button. That was fairly simple. ...
    4. runtime error: memory can not be read
      Hi all, The different behaviors of movies running in the director's authoring environment and runtime mode is nothing new. I can remember issues...
    5. Runtime CD query (not the simle read-only file question, but related)
      I'm a newbie, publishing my first DB on CD for a client. The DB is large (several hundred Meg), so the client feels the main DB should stay (as...
  3. #2

    Default Re: How To: Read AssemblyInfo Attributes @ runtime

    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" <ptakja@NOSPAM.corning.com> wrote in message
    news:065a01c34a1f$7cb9f870$a001280a@phx.gbl...
    > 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 Guest

  4. #3

    Default How To: Read AssemblyInfo Attributes @ runtime

    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.GetExecutingAssembl y, GetType
    >(AssemblyCopyrightAttribute)), AssemblyCopyrightAttribute)
    >
    >Dim objProduct As AssemblyProductAttribute = CType
    >(AssemblyProductAttribute.GetCustomAttribute
    >(System.Reflection.Assembly.GetExecutingAssembl y, GetType
    >(AssemblyProductAttribute)), AssemblyProductAttribute)
    >
    >Thanks!
    >
    >J. Ptak
    >
    >.
    >
    Jeff Ptak Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139