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 the 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.