title: GetCustomAttributes
body: <pre><code>    &lt;AttributeUsage(AttributeTargets.Property)&gt; _
  Private Class CustomAttrib
      Inherits Attribute
  
      Public Property DataTypeLength As Integer
  
  End Class
  
  Private Class TestClass
      &lt;CustomAttrib(DataTypeLength:=75)&gt; _
      Public Property MyProp As String
  End Class
  
  Dim properties = GetType(TestClass).GetFields(Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic)
  
  For each Prop As FieldInfo in Properties
  
      Dim attributes =    DirectCast(prop.GetCustomAttributes(GetType(TestClass), False), CustomAttrib())
  
    If Attributes.Any Then
      'get value of custom attribute
    End If
  Next
  </code></pre>
  
  <p>Ok no matter what i do attributes is always null/nothing. I have also tried the following also:</p>
  
  <pre><code>Attribute.GetCustomAttributes(prop)
  </code></pre>
  
  <p>This returns two attributes of type <code>CompilerGeneratedAttribute</code> and <code>DebuggerBrowsableAttribute</code></p>
  
  <p>What am i doing wrong here?</p>