Nov 14, 2010 02:52 PM
(This post was last modified: Nov 14, 2010 02:53 PM by Mr. Anderson.)
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
Happy Leeching!👍
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!👍


