Compiling using CodeCompiler.CompileAssemblyFromSourceBatch() results in an exception
Lypyl opened this issue · 1 comments
Lypyl commented
Error (101): The namespace
global::' already contains a definition for
Test'
Where Test is the name of one of the classes to be compiled (and no it's not already in the project).
It doesn't throw an error if you compile only 1 source string at a time, and CompileAssemblyFromFileBatch() works fine with any number of files.
The best I've been able to determine what is happening is in CompileAssemblyFromSourceBatch(), the subsequent:
Func<Stream> getStream = () => { return new MemoryStream(Encoding.UTF8.GetBytes(source ?? "")); };
overwrite the previous MemoryStreams that are stored in source files, so all the source files end up with the same code.