C# Debugger.IsAttached 調試啟動瀏覽器 VS if DEBUG 啟動調試內容


1. 程序集

Debugger:調試類

引用集:System.Diagnostics.Debug.dll

2. 方法使用

1.調用系統默認的瀏覽器方法:

//調用系統默認的瀏覽器 
System.Diagnostics.Process.Start("http://blog.csdn.net/testcs_dn");

2. Debugger.IsAttached 調試啟動瀏覽器

if (Debugger.IsAttached)
  {
      System.Diagnostics.Process.Start($"{baseAddress}/swagger");  //調試啟動瀏覽器
   } 

3.if DEBUG  啟動調試內容

#if DEBUG
       string baseAddress = "http://localhost:9000/";
#endif

3. 項目使用實例

4. #if DEBUG VS System.Diagnostics.Debugger.IsAttached

在Visual Studio中使用#if DEBUG System.Diagnostics.Debugger.IsAttached在Visual Studio中有什么區別?是否存在DEBUG設置了標志但沒有附加調試器的情況,或者在DEBUG未設置標志的情況下可以附加調試器的情況?


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM