почему то не те не твой пример не работают.
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using Microsoft.CSharp;
namespace ConsoleCompiler
{
internal class Program
{
[STAThread]
private static void Main(string[] args)
{
// Source code для компиляции
string source =
@"
namespace Foo
{
public class Bar
{
static void Main(string[] args)
{
Bar.SayHello();
}
public static void SayHello()
{
System.Console.WriteLine(""Hello World"");
}
}
}
";
CSharpCodeProvider provider = new CSharpCodeProvider();
string[] a ={"Foo.EXE"};
CompilerParameters compilerParams = new CompilerParameters
{OutputAssembly = "D:\\Foo.EXE", GenerateExecutable = true};//ОШИБКА
// Компиляция
CompilerResults results = provider.CompileAssemblyFromSource(compilerParams, source);
// Выводим информацию об ошибках
Console.WriteLine("Number of Errors: {0}", results.Errors.Count);
foreach (CompilerError err in results.Errors)
{
Console.WriteLine("ERROR {0}", err.ErrorText);
}
}
}
}
error CS1526: A new expression requires () or [] after type
|