Although you can achieve some aspects of your question with both Namespaces (System.CodeDom and System.Reflection.Emit) you can't mix the two different concepts and use the option(s) that better fits whatever you want to do.
If you just want to generate and compile C#\VB code maybe you want do use System.CodeDom:
This namespace can be used to model
the structure of a source code
document that can be output as source
code in a supported language using the
functionality provided by the
System.CodeDom.Compiler namespace.
Check this small example on how to define a method through CodeDom:
// Defines a method that returns a string passed to it.
CodeMemberMethod method1 = new CodeMemberMethod();
method1.Name = "ReturnString";
method1.ReturnType = new CodeTypeReference("System.String");
method1.Parameters.Add( new CodeParameterDeclarationExpression("System.String", "text") );
method1.Statements.Add( new CodeMethodReturnStatement( new CodeArgumentReferenceExpression("text") ) );
// A C# code generator produces the following source code for the preceeding example code:
// private string ReturnString(string text)
// {
// return text;
// }
As for the System.Reflection.Emit its used to generate and manipulate MSIL (Microsoft Intermediate Language) which is lowest-level human-readable programming language defined by the Common Language Infrastructure specification and used by the .NET Framework. Note that MSIL is now known as CIL (Common Intermediate Language):
The System.Reflection.Emit namespace
contains classes that allow a compiler
or tool to emit metadata and Microsoft
intermediate language (MSIL) and
optionally generate a PE file on disk.
The primary clients of these classes
are script engines and compilers.
The use of this approach leads you to learn CIL bytecode instructions which is a rather difficult and complex task even if you're familiar with assembly code and might not be ideal if what you want is rather simple and fast to implement. Check wikipedia article on CIL and CIL instructions list for a first impression.