Can we dynamically edit a method attribute using Reflection in C#?
- From: Abhi <Abhi@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 9 Dec 2007 23:42:01 -0800
I am using Reflection to invoke methods dynamically. I have got a special
requirement where I need to pass a value to method by setting the custom
method attribute. As I cannot change the signature of method to pass a new
parameter, I am setting the custom attribute of a given method and then
accessing the attribute from method. Since attribute value is decided at
runtime I want to change the attribute of particular method at runtime.
Following is what I am trying to do:
1.) Load the assembly.
2.) Dynamically set value of custom attribute of a particular method.
3.) Recompile the assembly so that when the particular method is invoked it
takes the updated attribute value.
4.) Invoke the method
I am interested to know how to do Step 2 & 3
I saw lots of example where we can generate the code, create and execute it
dynamically but not a example where we can modify the existing code and then
invoke the method using reflection. Please let me whether what I am trying to
do is possible or not using .Net3.0 or later.
Thanks,
Abhi
.
- Follow-Ups:
- Re: Can we dynamically edit a method attribute using Reflection in C#?
- From: Marc Gravell
- Re: Can we dynamically edit a method attribute using Reflection in C#?
- Prev by Date: Re: Need to dump file on HD in browser: what are my options?
- Next by Date: Re: Service Crashing
- Previous by thread: Service Crashing
- Next by thread: Re: Can we dynamically edit a method attribute using Reflection in C#?
- Index(es):
Relevant Pages
|