在网上看到不少VB.NET中实现脚本引擎的例子,本人现在正在做ASP.NET的开发,要实现类似的功能.
如:
在页面中放一个TextBox(多行),允许用户输入一段VB或C#的代码,用户按"确定"之后就编译并执行该段代码.请问如何实现?!
急!!!过两天就要交货了!!!!呜!!!

解决方案 »

  1.   

    ms-help://MS.MSDNQTR.2003FEB.2052/dnmag00/html/active1200.htm
      

  2.   

    如果要动态生成DLL基本上用下面的代码就可以实现了:   
        
        
      //从CompileCoder继承一个代码编译器如:   
        
      public   class   CompileCoder   
      {   
      public   static   CompilerResults   CompileCode(CodeDomProvider   provider,   string   fileName)   
      {   
      ICodeCompiler   compiler   =   provider.CreateCompiler();   
      CompilerParameters   cp   =   new   CompilerParameters(new   string[]   {   
      "System.dll",   
      "System.Drawing.dll"   
      },   filepath.LastIndexOf(".")+1)+"dll",   false);   
      cp.GenerateExecutable   =   false;         
      //cp.CompilerOptions="/resource:AppResource.resources";资源文件名字   
      string[]   fileBatch=new   string[1];   
      fileBatch[0]=filepath;   
      CompilerResults   cr   =   compiler.CompileAssemblyFromFileBatch(cp,   fileBatch);   
      return   cr;   
      }   
      }   
      //使用这个编译器   
      string   sCompileMessage   =   null;   
      CodeDomProvider   provider   =   new   CSharpCodeProvider(   );   
      CompilerResults   cr   =   CompileCoder.CompileCode(   provider,   "AppResource.cs"   );   
      if(   cr.Errors.Count   >   0   )   
      {   
      foreach(   CompilerError   ce   in   cr.Errors   )   
      sCompileMessage   +=   ce.ToString(   )   +   "\r\n";   
      }   
      else   
      {   
      sCompileMessage   =   cr.PathToAssembly   +   "   已生成文件.";   
      }