Is there a way to have a less-strict compilation with a CodeDomProvider? I am trying to compile and load dll files into my already running program by using:
public static String Compile(string commandName, string source = "")
{
private static CodeDomProvider compiler = new CSharpCodeProvider(new Dictionary<string, string>() { { "CompilerVersion", "v3.5" } });
private static CompilerParameters parameters = new CompilerParameters();
parameters.GenerateExecutable = false;
parameters.MainClass = commandName;
parameters.OutputAssembly = dll;
parameters.ReferencedAssemblies.Add("MCLight_.dll");
parameters.CompilerOptions = "/optimize";
parameters.WarningLevel = 4;
parameters.TreatWarningsAsErrors = false;
StreamReader sr = new StreamReader(sourcepath + "cmd" + commandName + ".cs");
results = compiler.CompileAssemblyFromSource(parameters, sr.ReadToEnd());
.....
}
The problem is that errors such as:
Error #CS0122 Message: 'MCLight.Independent' is inaccessible due to its protection level Line: 1178
and
Error #CS1501 Message: No overload for method 'Find' takes '1' arguments Line: 617
are being thrown.
Now I know for a fact this class compiles fine when I compile it as part of my solution in VS. But when compiled separately it's throwing these errors. Is there a way to have the compiler ignore these errors since I know it will hook into the application just fine?