天天看点

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文章、视频等优质内容。

 个人作品

    1、BIMFace.Community.SDK.NET

     开源地址:https://gitee.com/NAlps/BIMFace.SDK

     系列博客:

     系列视频

    2、ZCN.NET.Common

     开源地址:https://gitee.com/NAlps/zcn.net.common

 技术栈

 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 审图等研究与应用。

          多次参与电子政务、图书教育、生产制造等企业级大型项目研发与管理工作。

          熟悉中小企业软件开发过程:需求分析、架构设计、编码测试、实施部署、项目管理。通过技术与管理帮助中小企业快速化实现互联网技术全流程解决方案。

继续阅读