My program often compile c#-code and sometimes i got a ArgumentException like "The file name 'C:\Users--\AppData\Local\Temp\wvpc3m5m.0.cs' was already in the collection. Parameter name: fileName".
Settings of compiler is next:
public void Init()
{
this.compilerParameters = new CompilerParameters
{
GenerateExecutable = false,
GenerateInMemory = true
};
}
Compilation:
public CompilerResults Compile(String code)
{
CompilerResults result = this.codeProvider
.CompileAssemblyFromSource(this.compilerParameters, code);
return result;
}
I think that the codeProvider write passed string into a file, and sometimes he try to write in one and the same file twice.