Can we dynamically edit a method attribute using Reflection in C#?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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

.



Relevant Pages

  • Attribute question
    ... I can find out which dll method to invoke. ... write a custom attribute and give it to the developers to use to ... decorate the methods they want me to invoke during runtime. ... developers to put is just method name and its description. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Corruption of temporary BAT files for Custom Build Steps (VC++)
    ... one workaround for VS.NET 2003 is to move some or all of the ... custom build step into an external .bat file and invoke that from the ...
    (microsoft.public.vc.ide_general)
  • Custom Build Rule Always Getting Invoked
    ... I created a custom build rule for a certain file extension. ... project seems to only invoke the tool when the input file ...
    (microsoft.public.vsnet.ide)
  • custom page redirection
    ... Is there a possibilty to invoke a custom page from ... thanking all in advance, ...
    (microsoft.public.sharepoint.portalserver.development)
  • Re: java - invoke
    ... You have stumbled on one of the most subtle features of Java called ... You create call lists of parameters on the fly and invoke methods. ... It is a tool to allow java code to use arbitrary class files handed to ... You can usually get what you want without resorting to reflection ...
    (comp.lang.java.help)