天天看點

Visual Studio 調試(系列文章)

  調試是軟體開發過程中非常重要的一個部分,它具挑戰性,但是也有一定的方法和技巧。

  Visual Studio 調試程式有助于你觀察程式的運作時行為并發現問題。 該調試器可用于所有 Visual Studio 程式設計語言及其關聯的庫。 使用調試程式時,可以中斷程式的執行以檢查代碼、檢查和編輯變量、檢視寄存器、檢視從源代碼建立的指令,以及檢視應用程式占用的記憶體空間。

  本系列以 Visual Studio 2019 來示範調試的方法和技巧。希望能幫助大家掌握這些技巧。它們都很簡單,卻能幫你節約大量的時間。

Visual Studio 調試(系列文章)

調試方法與技巧

 Visual Studio 調試系列1 Debug 與 Release 模式

 Visual Studio 調試系列2 基本調試方法

 Visual Studio 調試系列3 斷點

 Visual Studio 調試系列4 單步後退來檢查舊應用狀态(使用使用 IntelliTrace 視窗)

 Visual Studio 調試系列5 檢查變量(使用自動視窗和局部變量視窗)

 Visual Studio 調試系列6 監視變量(使用監視視窗和快速監視視窗)

 Visual Studio 調試系列7 檢視變量占用的記憶體(使用記憶體視窗)

 Visual Studio 調試系列8 查找導緻程式崩潰的 DLL(使用子產品視窗)

 Visual Studio 調試系列9 調試器提示和技巧

 Visual Studio 調試系列10 附加到正在運作的程序

 Visual Studio 調試系列11 遠端調試

 Visual Studio 調試系列12 遠端調試部署在遠端計算機IIS上的ASP.NET應用程式

示例程式

後續的調試以下面的程式為示例進行示範說明。

Visual Studio 調試(系列文章)
Visual Studio 調試(系列文章)

1 using System;
  2 using System.Collections.Generic;
  3 
  4 namespace Demo002_NF45_CS50
  5 {
  6     class Program
  7     {
  8         static void Main(string[] args)
  9         {
 10             var shapes = new List<Shape>
 11             {
 12                 new Triangle(4,3),
 13                 new Rectangle(7,4),
 14                 new Circle(),
 15 
 16             };
 17 
 18             foreach (var shape in shapes)
 19             {
 20                 shape.Width = 10;
 21                 shape.Draw();
 22 
 23                 int num1 = 2, num2 = 0;
 24                 num1 = num1 / num2;
 25 
 26                 Console.WriteLine();
 27             }
 28 
 29             Console.WriteLine("Press any key to exit."); // 在調試模式下保持控制台打開
 30             Console.ReadKey();
 31         }
 32     }
 33 
 34     #region 調試示例
 35 
 36     /// <summary>
 37     ///  繪圖類(基類)
 38     /// </summary>
 39     public class Shape
 40     {
 41         #region 屬性
 42 
 43         /// <summary>
 44         ///  X 軸坐标
 45         /// </summary>
 46         public int X { get; private set; }
 47 
 48         /// <summary>
 49         ///  Y 軸坐标
 50         /// </summary>
 51         public int Y { get; private set; }
 52 
 53         /// <summary>
 54         ///  圖形高度
 55         /// </summary>
 56         public int Height { get; set; }
 57 
 58         /// <summary>
 59         ///  圖形寬度
 60         /// </summary>
 61         public int Width { get; set; }
 62 
 63         #endregion
 64 
 65         // 繪制圖形(虛方法)
 66         public virtual void Draw()
 67         {
 68             Console.WriteLine("Performing base class drawing tasks");// 執行基類繪圖任務
 69         }
 70     }
 71 
 72     /// <summary>
 73     ///  圓形
 74     /// </summary>
 75     class Circle : Shape
 76     {
 77         public override void Draw()
 78         {
 79             Console.WriteLine("Drawing a circle"); // 繪制一個圓
 80             base.Draw();
 81         }
 82     }
 83 
 84     /// <summary>
 85     ///  矩形
 86     /// </summary>
 87     class Rectangle : Shape
 88     {
 89         public Rectangle()
 90         {
 91           
 92         }
 93 
 94         public Rectangle(int width, int height)
 95         {
 96             Width = width;
 97             Height = height;
 98         }
 99 
100         public override void Draw()
101         {
102             Console.WriteLine("Drawing a rectangle"); // 繪制一個矩形
103             base.Draw();
104         }
105     }
106 
107     /// <summary>
108     ///  三角形
109     /// </summary>
110     class Triangle : Shape
111     {
112         public Triangle()
113         {
114 
115         }
116 
117         public Triangle(int width, int height)
118         {
119             Width = width;
120             Height = height;
121         }
122 
123         public override void Draw()
124         {
125             Console.WriteLine("Drawing a trangle");// 繪制一個三角形
126             base.Draw();
127         }
128     }
129 
130     #endregion
131 }      

View Code

成在管理,敗在經驗;嬴在選擇,輸在不學!  貴在堅持!

歡迎關注作者頭條号 張傳甯IT講堂,擷取更多IT文章、視訊等優質内容。

Visual Studio 調試(系列文章)

個人作品

1、BIMFace.Community.SDK.NET

     開源位址:https://gitee.com/NAlps/BIMFace.SDK

     系列部落格:https://www.cnblogs.com/SavionZhang/p/11424431.html

     系列視訊:https://www.cnblogs.com/SavionZhang/p/14258393.html

2、ZCN.NET.Common

     開源位址:https://gitee.com/NAlps/zcn.net.common

Visual Studio 調試(系列文章)

技術棧

 1、Visual Studio、.C#/.NET、.NET Core、MVC、Web API、RESTful API、gRPC、SignalR、Python

 2、jQuery、Vue.js、Bootstrap

 3、資料庫:SQLServer、MySQL、PostgreSQL、Oracle、SQLite、Redis、MongoDB、ElasticSearch、TiDB、達夢DM、人大金倉、 神通、南大通用 GBase、華為 GaussDB 、騰訊 TDSQL 、阿裡 PolarDB、螞蟻金服 OceanBase、東軟 OpenBASE、浪潮雲溪資料庫 ZNBase

 4、ORM:Dapper、Entity Framework、FreeSql、SqlSugar、分庫分表、讀寫分離

 5、架構:領域驅動設計 DDD、ABP

 6、環境:跨平台、Windows、Linux(CentOS、麒麟、統信UOS、深度Linux)、maxOS、IIS、Nginx、Apach

 7、移動App:Android、IOS、HarmonyOS、微信、小程式、快應用、Xamarin、uni-app、MUI、Flutter、Framework7、Cordova、Ionic、React Native、Taro、NutUI、Smobiler

 雲原生、微服務、Docker、CI/CD、DevOps、K8S;

 Dapr、RabbitMQ、Kafka、分布式、大資料、高并發、負載均衡、中間件、RPC、ELK;

 .NET + Docker + jenkins + Github + Harbor + K8S;

出處:www.cnblogs.com/SavionZhang

作者:張傳甯   微軟MCP、系統架構設計師、系統內建項目管理工程師、科技部創新工程師。

          專注于微軟.NET技術(.NET Core、Web、MVC、WinForm、WPF)、通用權限管理系統、工作流引擎、自動化項目(代碼)生成器、SOA 、DDD、 雲原生(Docker、微服務、DevOps、CI/CD);PDF、CAD、BIM 審圖等研究與應用。

          多次參與電子政務、圖書教育、生産制造等企業級大型項目研發與管理工作。

          熟悉中小企業軟體開發過程:需求分析、架構設計、編碼測試、實施部署、項目管理。通過技術與管理幫助中小企業快速化實作網際網路技術全流程解決方案。

本文版權歸作者和部落格園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接配接,否則保留追究法律責任的權利。

如有問題,可以通過郵件[email protected]聯系。共同交流、互相學習。

如果您覺得文章對您有幫助,請點選文章右下角【推薦】。您的鼓勵是作者持續創作的最大動力!