CompileAssemblyFromDomBatch and compile errors

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm constructing a bunch of code into a set of CodeCompileUnit's and then
attempting to compile using the CompileAssemblyFromDomBatch method.
This works great assuming the compile is successful. If the compile is not
successful, the CompilerResults has a Errors collection with a set
CompilerError objects to point out the errors.

Here's the problem; internally the C# compiler is generating a bunch of temp
files and the CompilerError.FileName points back to the temp file name where
the error is. It doesn't seem to have any reference back to the original
CodeCompileUnit, so I have no idea where the error is.

Is there a way to correlate the CompilerError or FileName back to
CodeCompileUnits that caused the error rather than temp files? Or do I have
to explicitly generate the files and then compile the files to know which
compile units contain the errors myself?
 
I accidentally found away around this problem.
I'm using a CodeSnippetCompileUnit because I was too lazy to build a
language independent CodeDom. The CodeSnippetCompileUnit has a LinePragma
object with filename and line #. When I set this before compilation, the
compiler uses my file name for the temp file. Who woulda thought?

What you would do to control the temp file name if you were using the base
CodeCompileUnit object, I don't know. That will be a later excersize.
 
Back
Top