C# How can I get from CompilerError instance exact text which caused the error
Could you please tell me how can I get from CompilerError instance exact text which caused the error. Edited:
What about using
compilerError.FileName
and reading th开发者_运维百科e file with text reader? I am trying to do so but it seems that Compiler doesn't create cs file that doesn't pass the compilation any suggestions?
This CompilerError
? : http://msdn.microsoft.com/en-us/library/system.codedom.compiler.compilererror.aspx
There are FileName
and Line
properties, that's the best you can get.
What are you compiling - is it entirely in-memory (CodeDOM)?
If so you can add code-line pragmas to your object model: http://msdn.microsoft.com/en-us/library/system.codedom.codelinepragma.aspx then you'll be able to link an error to a DOM element.
Or, you can compile from source, then you'll have the source code itself and can get the text from the line number.
The best your going to get is the line number.
精彩评论