P
Paul
Hi!
I have a problem:
I've declared some classes and decorated them with my Custom Attributes.
(say ClassA and ClassB)
Now I have some Type member (in fact this is FieldInfo.FieldType) which is
eq. typeof (ClassB).
And when I call GetCustomAttributes() for this Type I never gets the
attribute, that should be there.
When I call GetType().GetCustonAttributes() everything works fine.
Doeas object of the requested type for attributes must be instantiated ?
Thanks for any help.
Paul.
___ code for my example __
[MyAttribute()]
public class ClassA
{
public int iVal;
}
[MyOtherAttribute()]
public class ClassB
{
ClassA member ;
void foo()
{
foreach (MyAttribute arre in GetType().GetField
("member").GetCustomAttributes (typeof(MyAttribute), true))
{
// never enters here
// this loop never finds MyAttribute of ClassA of field
"member".
}
}
}
I have a problem:
I've declared some classes and decorated them with my Custom Attributes.
(say ClassA and ClassB)
Now I have some Type member (in fact this is FieldInfo.FieldType) which is
eq. typeof (ClassB).
And when I call GetCustomAttributes() for this Type I never gets the
attribute, that should be there.
When I call GetType().GetCustonAttributes() everything works fine.
Doeas object of the requested type for attributes must be instantiated ?
Thanks for any help.
Paul.
___ code for my example __
[MyAttribute()]
public class ClassA
{
public int iVal;
}
[MyOtherAttribute()]
public class ClassB
{
ClassA member ;
void foo()
{
foreach (MyAttribute arre in GetType().GetField
("member").GetCustomAttributes (typeof(MyAttribute), true))
{
// never enters here
// this loop never finds MyAttribute of ClassA of field
"member".
}
}
}