Hi Jason,

in our company we used ILDasm and ILAsm for manipulating assemblies. We
developed an OR-Mapping tool using this technique. We search for classes
with a certain Attribute and enhance the classes so that they implement an
additional interface. This interface is used by the framework for state
management and getting the private data of the objects. (For those of you
interested in this tool: it will be published at www.advanced-developers.de
in January 2003.)

Unfortunately I can't give out the code, but it might be interesting for
you, that it is easy to work that way. Parsing the IL is very easy. The IL
code is hierarchical in it's nature so that you can build a tree much like
a XML document. Use the composite pattern! We needed about 2 man days for
having a first working version (which got some more functionality with the
time).

The best thing are the "line" statements of the IL, which maintains the
ability to debug the original source code with the enhanced assembly - no
pdb manipulation necessary. It's funny to see, how the private members of
an object are filled "magically" with values if you step with the debugger
in an enhanced procedure.

If your assembly is signed, the enhanced assembly can be signed using the
same key file. All necessary information for that is stored in the original
assembly.

We also examined the ILX toolkit which is very complicated to use. I don't
recommend to use it if you only want to develop one certain tool. It might
be worth to explore if you want to develop a lot of enhancing tools.

If you choose to work with ILAsm and ILDasm, feel free to send me email and
ask questions.

Mirko

Reply via email to