<高手请进> 急! 关于C#动态执行代码...
using System.Text;
using Microsoft.CSharp;
using System.CodeDom.Compiler;
using System.Reflection;
namespace TestControls
{
public class ExecuteCSharp
{
public static void Eval()
{
//CSharpCodeProvider provider = new CSharpCodeProvider();
//ICodeCompiler compiler = provider.CreateCompiler();
CodeDomProvider compiler = new CSharpCodeProvider();
CompilerParameters cp = new CompilerParameters();
StringBuilder codeBuilder = new StringBuilder();
codeBuilder.AppendLine( "using System; ");
codeBuilder.AppendLine( "using System.Text; ");
codeBuilder.AppendLine( "using System.Windows.Forms; ");
codeBuilder.AppendLine( "using System.Collections.Generic; ");
codeBuilder.AppendLine();
codeBuilder.AppendLine( "namespace TestControls ");
codeBuilder.AppendLine( "{ ");
codeBuilder.AppendLine( " public class Test ");
codeBuilder.AppendLine( " { ");
codeBuilder.AppendLine( " public void Exec() ");
codeBuilder.AppendLine( " { ");
codeBuilder.AppendLine( " MessageBox.Show(\ "测试ing...\ "); ");
codeBuilder.AppendLine( " } ");