I'm trying to develop a code compiler using C# but the problem is that I'm getting These Errors.
Error: c:\Users\ss\AppData\Local\Temp\xxpatmuh.0.cs(3,14) : error CS0234: The type or namespace name 'ComponentModel' does not exist in the namespace 'System' (are you missing an assembly reference?)<br />
Line:3<br />
Error: c:\Users\ss\AppData\Local\Temp\xxpatmuh.0.cs(6,14) : error CS0234: The type or namespace name 'Management' does not exist in the namespace 'System' (are you missing an assembly reference?)<br />
Line:6<br />
Error: c:\Users\ss\AppData\Local\Temp\xxpatmuh.0.cs(7,14) : error CS0234: The type or namespace name 'Net' does not exist in the namespace 'System' (are you missing an assembly reference?)<br />
Line:7<br />
Error: c:\Users\ss\AppData\Local\Temp\xxpatmuh.0.cs(8,14) : error CS0234: The type or namespace name 'Net' does not exist in the namespace 'System' (are you missing an assembly reference?)<br />
Line:8<br />
Error: c:\Users\ss\AppData\Local\Temp\xxpatmuh.0.cs(127,69) : error CS0246: The type or namespace name 'AsyncCompletedEventArgs' could not be found (are you missing a using directive or an assembly reference?)<br />
Line:127
PS: This is what I have in the reference:-
Screenshot
What I have tried:
Source.cs
namespace Builder
{
using Microsoft.CSharp;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
public class Source
{
public static void Editor(string title, string filename, string message)
{
string SourceCode = Properties.Resources.Stub;
SourceCode = SourceCode.Replace("[Title]", title);
SourceCode = SourceCode.Replace("%Path%", filename);
SourceCode = SourceCode.Replace("%Contents%", message);
var ProviderOptions = new Dictionary<string, string> { { "CompileVersion", "v.4.7" } };
using (var provider = new CSharpCodeProvider())
{
var Params = new CompilerParameters
{
OutputAssembly = "Build.exe",
GenerateExecutable = true,
CompilerOptions = "/target:exe"
};
CompilerResults results = provider.CompileAssemblyFromSource(Params, SourceCode);
if (!results.Errors.HasErrors)
{
MessageBox.Show("Created", "rSuccessrr", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
foreach (CompilerError compilerError in results.Errors)
{
File.AppendAllText("Error.txt", $"Error: {compilerError.ToString()}\r\nLine:{compilerError.Line}\r\n");
}
}
}
}
}
}
Stub.txt
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Management;
using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Threading;
using System.Reflection;
namespace Stub
{
internal static class Program
{
public static void Main(){
}
}