This is working fine for me.
Can you post more info - sample class and result? I created a class with 1
private, 1 public and 1 static field, then marked them all with
MyCustomAttribute. I ran the app and it said there were 3 fields as
expected.
HTH;
Eric Cadwell
http://www.origincontrols.com
My app is ASP.NET. Maybe it is a security issue? Here are some code
snippets:
public class WebForm1 : System.Web.UI.Page
{
[MaintainState(StateType.View)] // This user-defined attribute
does not show up in list.
private String MyValue; // If I change this to
public, it works fine.
....
} // end of class
-----------------------------------------------------
The attribute class is defined as follows:
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class MaintainStateAttribute : Attribute
{
private StateType _SType;
public MaintainStateAttribute(StateType S) // StateType is an
enumerator.
{
_SType = S;
}
// This static method in the attribute class tries to get the attributes for
the passed in object.
// The object passed in is of the class defined WebForm1 (snippet shown
above).
public static void GetAttrs(object StateObj)
{
Type T = StateObj.GetType();
int Count = 0;
MemberInfo[] MemberArray;
object[] AttributeArray;
MemberArray = T.GetMembers(BindingFlags.Instance |
BindingFlags.Static |
BindingFlags.Public |
BindingFlags.NonPublic);
foreach (MemberInfo M in MemberArray)
{
AttributeArray =
M.GetCustomAttributes(typeof(MaintainStateAttribute),true);
foreach(MaintainStateAttribute A in AttributeArray)
{
++Count;
}
}
// Count is 0 when I get here.
}
}
public enum StateType
{
Application,
Session,
View,
Cookie
}

Signature
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.
EmailID = varnk
Domain = Diebold.com
-----------------------------------
> This is working fine for me.
>
[quoted text clipped - 6 lines]
> Eric Cadwell
> http://www.origincontrols.com