I tried another path: to modify an existing custom attribute, and it works! It is a simpler solution but not so clean ;)
PS: I don't know why there isn't more publicity around cecil. The tool and its possibilities are amazing! Because there is not help and there are no samples, tutorials, it is a pain to find you way without personal help on the forum ( if you are lucky to get a link to it) .But forum is also suprisingly small: only 90 posts? What's up? On Jan 10, 2008 12:30 AM, Jb Evain <[EMAIL PROTECTED]> wrote: > > Hey, > > On 1/9/08, ursuletzu <[EMAIL PROTECTED]> wrote: > > //// PROBLEM 1: WHAT SHOULD I PASS TO CustomAttribute constructor, > > what MethodReference? I cannot ///// pass null because i get an > > exception! > > How surprising :) > > > assembly.CustomAttributes.Add(new > > CustomAttribute( ??? ) ); > > > > I think it might be a constructor but i need your help here: > > > > PROBLEM 2: If it is a constructor, I can't get a grip on one, > > Attribute has a default constructor and i cannot get it with > > Reflection: > > You need to create your own default constructor for > CecilGeneratedAttribute, add it to its .Constructors collection, and > pass it to the CustromAttribute constructor. > > -- > Jb Evain <[EMAIL PROTECTED]> > > > > --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~---
