最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
如何 动态编译自己写的代码
时间:2008-01-12 编辑:简简单单 来源:一聚教程网
CSharpCodeProvider _coder=new CSharpCodeProvider();
ICodeCompiler complier=_coder.CreateCompiler();
CompilerParameters _par=new CompilerParameters();
_par.GenerateExecutable=true;
_par.OutputAssembly="sy1.exe";//设置应用程序名
_par.MainClass="sy1";//设置主类
_par.IncludeDebugInformation=true;
foreach(Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
{
_par.ReferencedAssemblies.Add(asm.Location);
}
string get_Code=_code;
CompilerResults _res=complier.CompileAssemblyFromSource(_par,get_Code);
if(_res.Errors.Count>0)
{
ErrInfo pEi=new ErrInfo();
pEi.Show();
ListBox getList=pEi.getList;
foreach(CompilerError err in _res.Errors)
{
getList.Items.Add(err.ErrorText);
}
}
else
{
MessageBox.Show("success");
}
ICodeCompiler complier=_coder.CreateCompiler();
CompilerParameters _par=new CompilerParameters();
_par.GenerateExecutable=true;
_par.OutputAssembly="sy1.exe";//设置应用程序名
_par.MainClass="sy1";//设置主类
_par.IncludeDebugInformation=true;
foreach(Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
{
_par.ReferencedAssemblies.Add(asm.Location);
}
string get_Code=_code;
CompilerResults _res=complier.CompileAssemblyFromSource(_par,get_Code);
if(_res.Errors.Count>0)
{
ErrInfo pEi=new ErrInfo();
pEi.Show();
ListBox getList=pEi.getList;
foreach(CompilerError err in _res.Errors)
{
getList.Items.Add(err.ErrorText);
}
}
else
{
MessageBox.Show("success");
}
-
上一个: 一个简单的代码生成“器”
相关文章
- SpringBoot测试配置属性与web启动环境解析 10-24
- vue中将el-switch值true、false改为number类型的1和0解析 10-24
- Vue中的路由配置项meta使用解读 10-24
- SpringBoot自定义bean绑定解析 10-24
- SpringBoot常用计量与bean属性校验和进制数据转换规则解析 10-24
- 工厂方法在Spring框架中的运用介绍 10-24