What are some pros/cons for using the Reflection.Emit library versus CodeDOM for dynamically generating code at runtime?
I am trying to generate som
Code that targets CodeDom tends to be easier to maintain, since you're generating C# code and not IL (more people can read C# than IL). Futhermore, if you get your CodeDom code wrong, you get a compiler error; if you generate invalid IL, you get a fatal exception or a crash.
However, because CodeDom invokes the csc.exe
compiler, it's a little slower to get the code ready for use. With Reflection.Emit, you can generate code directly into memory.
CodeDom is probably fine for most things; the XmlSerializer
and the WinForms designer use it.