pagates,
Ok, I understand now.
So, when you have the attribute like this:
[ACustomAttribute("Some Custom Attribute Value")]
public string SomeProperty
The runtime constructs an instance of ACustomAttribute passing the value
of "Some Custom Attribute Value". What the constructor does with this is up
to the attribute class. It's like any other class in this sense.
Typically, however, it will be exposed as a property. So, on the
ACustomAttribute class, there should be some sort of property that exposes
the value. When you call GetCustomAttributes, you can cast the return value
to an instance of ACustomAttribute and then access the property to get the
value (assuming it is exposed as such).

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> Hi Nicholas,
>
[quoted text clipped - 54 lines]
>> > Thanks,
>> > pagates
bonk - 14 May 2007 09:51 GMT
This approach is only possible if you can actually cast to the
CustomAttribute. If I reflect on an Assembly that also declares the
CustomAttribute Type I will not be able to cast to this Attribute type
because I do not reference that assembly. How could this issue be
solved ?
On Mar 29, 6:01 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.com> wrote:
> pagates,
>
[quoted text clipped - 82 lines]
>
> - Show quoted text -
Marc Gravell - 14 May 2007 10:04 GMT
Fist - you can't access *parameters*, but you can access *properties*;
and there-in lies the key.
If you don't want to reference the assembly, then perhaps use the
System.ComponentModel to access the values at runtime - i.e. (notepad
code; not compile-tested)
foreach(Attribute untypedAttribute in ...) { // presumably
GetAttributes() etc
Debug.WriteLine(untypedAttribute.GetType().Name);
foreach(PropertyDescriptor property in
TypeDescriptor.GetProperties(untypedAttribute)) {
Debug.WriteLine(string.Format("{0}={1}", property.Name,
property.GetValue(untypedAttribute)));
}
}
If you want to work with a *specific* attribute, then my first choice
would be to reference it! Otherwise, perhaps filter on FQN on
FullName.
Marc