How to get error line number of code using try-catch

前端 未结 10 929
轮回少年
轮回少年 2020-12-05 13:08

I want to get line number of code which cause error. For example;

static void Main(string[] args)
{
    using (SqlConnection conn = new SqlConnection(bagcum)         


        
10条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-05 14:03

    To get line numbers, you need your application to be in Debug mode or include the debug symbols in the same folder (the .pdb file) for line numbers to appear. You code as posted should then work.

提交回复
热议问题