[Mono-dev] Re: Adding Custom Attributes to Assembly

vijaya raghava mutharaju m.vijayaraghava at gmail.com
Tue Feb 21 09:04:50 EST 2006


            I was thinking if the following code would do what I was asking

                 1)  AssemblyDefinition assembly1 =
                      AssemblyDefinition assembly2 =

                       {     if(type is  MyAttribute)
                             {  // Import MyAttribute into assembly2
                2)  MyAttribute attribute = new MyAttribute("some
                     But it still leaves the issue of how to assign a proper
parent(in my case a class in assembly2) to MyAttribute.

              Excuse me if the above code is completely off target. Iam new
to Cecil.

          Thank you.

On 2/21/06, vijaya raghava mutharaju <m.vijayaraghava at gmail.com> wrote:
>        Hello,
>             I want to add custom attributes to an existing assembly. I
> want to do the following steps.
>                      1)  Refer the class MyAttribute which is in the
> assembly MyAssembly.exe, so that I can import into the current assembly -
> AnotherAssembly.exe
>                       2)  Add this attribute (MyAttribute constructor with
> proper arguments) on top of some of the classes in AnotherAssembly.exewhich is the one that is to be modified.
>                       3) Save it back to disk - I know
> AssemblyDefinition.SaveAssembly() can be used for that.
>            Please can you tell me how these steps can be done using
> Mono.Cecil.
>            Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060221/ade5f685/attachment.html 

More information about the Mono-devel-list mailing list