How to dynamically compile yourself write code

xiaoxiao2021-03-06  60

CsharpcodeProvider _coder = new csharpcodeProvider (); icodeCompiler Complier = _Coder.createCompiler (); CompilerParameters_Par = new compilerParameters (); _par.generateexecutable = true;

_PAR.Outputassembly = "sy1.exe"; // Set the application name _Par.MainClass = "SY1"; // Set the primary class _par.includebuginformation = 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.Error) {

getList.Items.add (Err.Erortext);}} else {messagebox.show ("success");}

转载请注明原文地址:https://www.9cbs.com/read-113642.html

New Post(0)