第一 ,引用命名空间using System.Runtime.CompilerServices;

第二,编写一个方法

  void ShowDetail(Exception ex,
            [CallerFilePath] string path=null,
            [CallerMemberName] string name=null)
        {
           
            Console.WriteLine("文件路径:"+path);
            Console.WriteLine("调用者的名字:"+name);
            Console.WriteLine("发生异常的行号:"+ex.StackTrace.Substring(ex.StackTrace.Length - 3, 3));
            Console.WriteLine("异常信息:"+ex.Message);
          
        }

  写一个精确定位异常的方法

写一个精确定位异常的方法

  

相关文章:

  • 2021-06-20
  • 2021-09-02
  • 2021-08-25
  • 2022-12-23
  • 2021-12-25
  • 2021-09-03
  • 2021-11-21
  • 2021-07-05
猜你喜欢
  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2021-08-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案