Announcement

Collapse
No announcement yet.

Attribut AssemblyVersionAttribute

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Attribut AssemblyVersionAttribute

    Hallo,

    folgender Code produziert mir als Ergebnis für immer Nothing. Wo liegt der Fehler?

    Dim asm As Reflection.Assembly
    Dim att As Reflection.AssemblyVersionAttribute

    asm = Reflection.Assembly.GetExecutingAssembly()
    att = DirectCast(Attribute.GetCustomAttribute(asm, GetType(Reflection.AssemblyVersionAttribute), False), Reflection.AssemblyVersionAttribute)

    Kann mir jemand helfen?

    Grüße

    Zimmi

  • #2
    Hallo,

    die Versionsnummer kann einfacher ausgelesen werden:

    <div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border-top: windowtext 1pt solid; padding-top: 0pt; border-left: windowtext 1pt solid; padding-left: 0pt; border-right: windowtext 1pt solid; padding-right: 0pt; border-bottom: windowtext 1pt solid; padding-bottom: 0pt;"><p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">Dim</span> asm <span style="color: blue;">As</span> System.Reflection.Assembly</p><p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; asm = System.Reflection.Assembly.GetExecutingAssembly()</p><p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">Dim</span> sVersion <span style="color: blue;">As</span> <span style="color: blue;">String</span> = asm.GetName().Version.ToString()</p><p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; MessageBox.Show(sVersion)</p></div>


    Wenn die Attribute direkt ausgelesen werden sollen, könnte das so aussehen:

    <div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border-top: windowtext 1pt solid; padding-top: 0pt; border-left: windowtext 1pt solid; padding-left: 0pt; border-right: windowtext 1pt solid; padding-right: 0pt; border-bottom: windowtext 1pt solid; padding-bottom: 0pt;"><p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">Dim</span> asm <span style="color: blue;">As</span> System.Reflection.Assembly</p><p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; asm = System.Reflection.Assembly.GetExecutingAssembly()</p><p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">Dim</span> aTitle <span style="color: blue;">As</span> System.Reflection.AssemblyTitleAttribute</p><p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; aTitle = <span style="color: blue;">CType</span>(asm.GetCustomAttributes( _</p><p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <span style="color: blue;">GetType</span>(System.Reflection.AssemblyTitleAttribute), <span style="color: blue;">False</span>)(0), _</p><p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; System.Reflection.AssemblyTitleAttribute)</p><p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">If</span> (aTitle <span style="color: blue;">IsNot</span> <span style="color: blue;">Nothing</span>) <span style="color: blue;">Then</span></p><p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; MessageBox.Show(aTitle.Title.ToString())</p><p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">End</span> <span style="color: blue;">If</span></p></div>

    Comment

    Working...
    X