Link to home
Start Free TrialLog in
Avatar of viswasiva
viswasiva

asked on

Problem in working with Custom attributes

Team.,
    Could you please let me know whether it is possible to set the value of a customattribute (derived from System.Attribute) in .net using reflection? if s, then will be possible to have different values for the customattribute for different instances of the class? Hope I am clear..
        This is a bit urgent.Any guidance will really be of great help to me..
Thanks in advance..

Regards,
Viswa
ASKER CERTIFIED SOLUTION
Avatar of SThorogood
SThorogood

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of viswasiva
viswasiva

ASKER

Thanks for the inputs. I am using this custom attributes to represent the metadata of my class. I wanted to store different values of the meta data for different instances. Could u pls tell me If there is a possibility of changing the customattribute property value? When wil be the setter function called..????
We have GetCustomAttributes() method to get the values of the custom attributes..I want to know whether it can be set? If so, what is the function used for that?
I'm not an expert on reflection, but i suspect that what you are trying to do is not possible and isn't what attributes are intended for.

Could you not use class properties to store instance-specific metadata instead?
Yeah..I can..But am a bit curious to know what will be the use of setter function in the customattribute class..and when will it be called. I am trying to make use of that..if possible.
Avatar of Bob Learned
AFAIK, attributes are descriptors for the methods, properties, at compile time, and cannot be set at run-time.

Bob