Hi Fabian, thank you. I'll start from there.
Pierre
You can write an unmanaged profiler that adds the attribute at load time. Have a look at Profiling.doc and Metadata Unmanaged.doc/Assembly Metadata Unmanaged.doc in your FrameworkSDK\Tool Developers Guide\Docs folder.
You will have to: Write a COM component implementing ICorProfilerCallback Intercept the ModuleLoadFinished or ClassLoadFinished events Get the IMetaDataAssemblyEmit and IMetaDataEmit interfaces for the module you want to manipulate Add a MemberRef to the attribute's constructor (and probably an AssemblyRef and TypeRef as well) Finally add the custom attribute
This is just a rough outline, so be sure to read the documents I mentioned.
Fabian Schmied
-----Ursprüngliche Nachricht----- Von: Pierre [mailto:[EMAIL PROTECTED] Gesendet: Mo 24.03.2003 11:10 An: [EMAIL PROTECTED] Cc: Betreff: [ADVANCED-DOTNET] Adding a custom attribute to a type
Hello, I have an assembly containing a Type and I need to add an attribute to a method of that type at run-time. I tryied to look inside System.Reflection.Emit but I didn't found the way of adding the custom attribute of an already created type.
Someone suggested that there are some unmanaged APIs to do that but I didn't found any document talking about them.
Thanks for any help, Pierre
=================================== This list is hosted by DevelopMentor® http://www.develop.com You may be interested in Guerrilla .NET, 24 March 2003, in London and Boston http://www.develop.com/courses/gdotnet
View archives and manage your subscription(s) at http://discuss.develop.com