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