For example, the code below can complile ok, but throw an exception at runtime. My question is, how to get the runtime error line number ? Thanks.
using System;
using System.Collections.Generic;
using System.Text;
namespace mytempNamespace {
public class mytempClass : {
public void show() {
String msg=null;
String msgNew=msg.Substring(3);
}
}
}
When i compile , the result is ok
CodeDomProvider compiler = CSharpCodeProvider.CreateProvider("CSharp");
CompilerResults compilerResults = compiler.CompileAssemblyFromSource(parms, myClassCode);
Assembly assembly = compilerResults.CompiledAssembly;
When i invokde the method "show", the assembly throw an exception. How can i get runtime error line number in CodeDom?
Use StackTrace to extract an exception's file, line, and column information.
You'll need to compile your code with
CompilerParameters
set up to output debugging information:Hope that helps!