Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

[Source]CodeDom for C#

Not sure if this has been posted(I searched and the only result I got was a $harecash link).
All Credit the Prototype or whoever made the visual Basic one.

You must Reference the Microsoft.CSharp dll and Microsoft.VisualBasic in order to use this.
I removed the error displaying because it was causing errors :p

Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.CodeDom.Compiler;
using Microsoft.VisualBasic;

namespace WindowsFormsApplication1
{
    class icompilecs
    {
  public static void GenerateExecutable(string Output, string Source, string Icon)
  {

    ICodeCompiler Compiler = (new Microsoft.CSharp.CSharpCodeProvider()).CreateCompiler();
    CompilerParameters Parameters = new CompilerParameters();
    CompilerResults cResults = default(CompilerResults);

    Parameters.GenerateExecutable = true;
    Parameters.OutputAssembly = Output;
    Parameters.ReferencedAssemblies.Add("System.dll");
    Parameters.ReferencedAssemblies.Add("System.Data.dll");
    Parameters.ReferencedAssemblies.Add("System.Windows.Forms.dll");

    dynamic Version = new Dictionary<string, string>();
    Version.Add("CompilerVersion", "v2.0");

    string ICO = System.IO.Path.GetTempPath() + "\\iCompiler.ico";

    if (!string.IsNullOrEmpty(Icon))
    {
    System.IO.File.Copy(Icon, ICO);
    Parameters.CompilerOptions += " /win32icon:" + ICO;
    }

    cResults = Compiler.CompileAssemblyFromSource(Parameters, Source);

    if (cResults.Errors.Count > 0)
    {
    foreach (object CompilerError_loopVariable in cResults.Errors)
    {

    }

    }
    else if (cResults.Errors.Count == 0)
    {
    }
    if (!string.IsNullOrEmpty(Icon))
    {
    System.IO.File.Delete(ICO);
    }
  }

    }
}

Happy Leeching!👍
Why is there empty loops/else statements?
because the error code displayer caused it have errors. I am actually fixing this now.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by WubixMar 24, 2018 06:47 PM 5 242 Mar 24, 2018 06:47 PM
Last Post: Wubix
[.NET] by KrypteXMay 11, 2016 03:52 PM 25 2,042 May 11, 2016 03:52 PM
Last Post: KrypteX
[.NET] by Slavoj ŽižekJun 17, 2015 01:00 AM 13 1,214 Jun 17, 2015 01:00 AM
Last Post: ShittyAdvice