..在VS debug 模式下会“无法捕获” System.NullReferenceException。。。。。。但是在release 或者外部运行是能捕获的。

test code :

 Form2 f = null;
            try
            {
              
                f.Dispose();
            }
            catch (NullReferenceException ex)
            {
                MessageBox.Show("get:"+ex.Message);
            }

其实只是VS 在调试模式故意弹出的断点,可以在调试时候出现的Exception Settings窗口设置里取消勾选“System.NullReferenceException”(在debug的时候回出来这个Exception Settings窗口,然后查找"NullReferenceException“”)

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-22
  • 2022-03-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-10
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
  • 2021-09-15
  • 2021-09-27
相关资源
相似解决方案