c# 无法捕获 System.NullReferenceException?


..在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“”)

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM