CSharpCodeProvider codeProvider = new CSharpCodeProvider();
ICodeCompiler MyCompiler = codeProvider.CreateCompiler();
CompilerParameters myParameters = new CompilerParameters();
myParameters.GenerateExecutable = true;
myParameters.OutputAssembly = @"prog.exe";
myParameters.TreatWarningsAsErrors = false;
CompilerResults results = myCompiler.CompileAssemblyFromFile(myParameters,"prog.txt");
How can I write this code to eliminate this warning:
System.CodeDom.Compiler.CodeDomProvider.CreateCompiler()' is obsolete: '"Callers should not use the ICodeCompiler interface and should instead use the methods directly on the CodeDomProvider class. Those inheriting from CodeDomProvider must still implement this interface, and should exclude this warning or also obsolete this method.**
Use this method instead:
CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp");
Extended:
if (CodeDomProvider.IsDefinedLanguage(language))
{
CodeDomProvider provider = CodeDomProvider.CreateProvider(language);
// ...
}
else
Console.WriteLine("ERROR");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With