OK, thanks for the answer to my comment. I've just tested it and the problem is in the
CompilerParameters
passed to
CompileAssemblyFromSource
and you must have missed the reference to System.dll
e.g.
String[] referenceAssemblies = { "System.dll" };
CompilerParameters cp = new CompilerParameters(referenceAssemblies);
cp.GenerateInMemory = true;
cp.GenerateExecutable = false;
cp.OutputAssembly = "My.Dynamic.dll";
CompilerResults cr = RuntimeCompiler.CompileAssemblyFromSource(cp, source);
Without that reference I get that same error
"error CS0234: The type or namespace name 'ComponentModel' does not exist in the namespace 'System' (are you missing an assembly reference?)"
when I execute the code.
Alan.