A
Abhi
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
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