110,556
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Model
{
public class UserInfo
{
public virtual int ID { get; set; }
public virtual string UserID { get; set; }
public virtual string UserName { get; set; }
}
}
using Microsoft.CSharp;
using System.CodeDom.Compiler;
using System.IO;
CSharpCodeProvider objCSharpCodePrivoder=new CSharpCodeProvider();
CompilerParameters paras = new CompilerParameters();
paras.GenerateExecutable = false; //编译成exe还是dll
//paras.ReferencedAssemblies.Add("System.dll");
paras.GenerateInMemory = false; //是否写入内存,不写入内存就写入磁盘
paras.OutputAssembly = "C:\\UserInfo.dll"; //输出路径
StreamReader sr = new StreamReader(@"C:\UserInfo.cs");
String txtStr = sr.ReadToEnd();
CompilerResults result = objCSharpCodePrivoder.CompileAssemblyFromSource(paras, txtStr);