Я был под впечатлением, что этот класс только что обернулся вокруг csc.exe , идея, которая, по -видимому, подтверждена моим брандмауэром (мое приложение пытается получить доступ к CSC.Exe ). Возможно, мне просто нужно установить Options.compileroptions < /code> на что -то?
Код: Выделить всё
protected virtual void Compile()
{
Microsoft.CSharp.CSharpCodeProvider csProvider = new Microsoft.CSharp.CSharpCodeProvider();
CompilerParameters options = new CompilerParameters();
options.GenerateExecutable = false;
options.GenerateInMemory = true;
options.IncludeDebugInformation = true;
foreach (string s in this.ReferencedAssemblies)
{
options.ReferencedAssemblies.Add(s);
}
CompilerResults result;
string source = this.CodeTemplate;
// [snip] Do some manipulation to fill in the template with values.
result = csProvider.CompileAssemblyFromSource(options, source);
this.HasErrors = result.Errors.HasErrors;
this.Errors = new CompilerError[result.Errors.Count];
result.Errors.CopyTo(Errors, 0);
if (HasErrors && ThrowOnErrors)
throw new InvalidProgramException("The code currently stored in the " + this.GetType() + " cannot be compiled.");
else if (HasErrors)
return;
this.CompiledAssembly = result.CompiledAssembly;
}
У меня есть ссылки на mscorlib , system.core , system.text и одну из моих собственных собраний на данный момент.
Подробнее здесь: https://stackoverflow.com/questions/120 ... w-features