c# - how to prevent to open in console my dynamically generated exe -


i working in c# 4.0, want generate executable file dynamically, used code dome, when executes open in console , after form displays, want generate winform executable file. how can achieve aim. code below :

string code = @" using system; using system.windows.forms;  namespace csbss { static class program { /// <summary> /// main entry point application. /// </summary> [stathread] static void main() { application.enablevisualstyles(); application.setcompatibletextrenderingdefault(false); application.run(new form1()); } }  public class form1 : form { } }  ";  codedomprovider codeprovider = codedomprovider.createprovider("csharp");  string tempfolder = @"..\dynamicoutput"; string output = system.io.path.combine(tempfolder, @"csbss.exe"); if (!system.io.directory.exists(tempfolder)) {     system.io.directory.createdirectory(tempfolder); } else {     if (system.io.file.exists(output)) system.io.file.delete(output); }  system.codedom.compiler.compilerparameters parameters = new compilerparameters(); parameters.referencedassemblies.add("system.dll"); parameters.referencedassemblies.add("system.windows.forms.dll");  parameters.tempfiles = new tempfilecollection(tempfolder, false); //make sure generate exe. parameters.generateexecutable = true; parameters.generateinmemory = false; parameters.outputassembly = output;   compilerresults results = codeprovider.compileassemblyfromsource(parameters, code);  string outputmsg = ""; if (results.errors.count > 0) {     string msgdescr = "";     foreach (compilererror comperr in results.errors)     {         msgdescr += "line number " + comperr.line +                     ", error number: " + comperr.errornumber +                     ", '" + comperr.errortext + ";" +                     environment.newline + environment.newline;     }     outputmsg = @"error occured while generating executable file, please check following internal error  " + msgdescr;     //return false; } else {     outputmsg = "executable file has been generated successfully."; } 

specify output type windows application using compileroptions:

parameters.compileroptions = "/target:winexe"; 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -