I am trying to compile code with codeDom with this function:
public static bool Compile(string Output, string Source, string Icon, string resources)
{
CompilerParameters Parameters = new CompilerParameters();
CompilerResults cresults = default(CompilerResults);
Dictionary<string, string> providerOptions = new Dictionary<string, string>();
providerOptions.Add("CompilerVersion", "v2.0");
CSharpCodeProvider Compiler = new CSharpCodeProvider(providerOptions);
Parameters.GenerateExecutable = true;
Parameters.TreatWarningsAsErrors = false;
Parameters.OutputAssembly = Output;
Parameters.EmbeddedResources.Add("System");
Parameters.CompilerOptions = "/target:winexe /platform:x86";
if (!string.IsNullOrEmpty(Icon))
{
Parameters.CompilerOptions += " /win32icon" + Icon;
}
cresults = Compiler.CompileAssemblyFromSource(Parameters, Source);
if (cresults.Errors.Count > 0)
{
foreach (CompilerError compile_error in cresults.Errors)
{
CompilerError error = compile_error;
MessageBox.Show(error + "");
}
return false;
}
return true;
}
source has these libarys (not sure if it's libarys I'm rather a java develloper):
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Xml;
using System.Data.SQLite;
using System.Data;
using System.Text;
using System.Collections.Specialized;
using System.Net;
using Dns = System.Net.Dns;
using AddressFamily = System.Net.Sockets.AddressFamily;
using System.Reflection;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.ComponentModel;
using System.IO;
using System.Security.Cryptography;
But when I compile I get these errors:
c:\Users\Augustin\AppData\Local\Temp\odq0sdk5.0.cs(3,14) : error CS0234: The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?)
c:\Users\Augustin\AppData\Local\Temp\odq0sdk5.0.cs(4,14) : error CS0234: The type or namespace name 'Xml' does not exist in the namespace 'System' (are you missing an assembly reference?)
c:\Users\Augustin\AppData\Local\Temp\odq0sdk5.0.cs(5,14) : error CS0234: The type or namespace name 'Data' does not exist in the namespace 'System' (are you missing an assembly reference?)
c:\Users\Augustin\AppData\Local\Temp\odq0sdk5.0.cs(6,14) : error CS0234: The type or namespace name 'Data' does not exist in the namespace 'System' (are you missing an assembly reference?)
c:\Users\Augustin\AppData\Local\Temp\odq0sdk5.0.cs(8,26) : error CS0234: The type or namespace name 'Specialized' does not exist in the namespace 'System.Collections' (are you missing an assembly reference?)
c:\Users\Augustin\AppData\Local\Temp\odq0sdk5.0.cs(9,14) : error CS0234: The type or namespace name 'Net' does not exist in the namespace 'System' (are you missing an assembly reference?)
c:\Users\Augustin\AppData\Local\Temp\odq0sdk5.0.cs(16,14) : error CS0234: The type or namespace name 'ComponentModel' does not exist in the namespace 'System' (are you missing an assembly reference?)
c:\Users\Augustin\AppData\Local\Temp\odq0sdk5.0.cs(10,20) : error CS0234: The type or namespace name 'Net' does not exist in the namespace 'System' (are you missing an assembly reference?)
c:\Users\Augustin\AppData\Local\Temp\odq0sdk5.0.cs(11,30) : error CS0234: The type or namespace name 'Net' does not exist in the namespace 'System' (are you missing an assembly reference?)
c:\Users\Augustin\AppData\Local\Temp\odq0sdk5.0.cs(60,14) : error CS0246: The type or namespace name 'DataTable' could not be found (are you missing a using directive or an assembly reference?)
How can I solve these errors?