找回密码
 立即注册
相关推荐换一批
  1. YY/T 0857-2011 椎体切除模型中脊柱植入物试验方法
  2. YY/T 0961-2014 脊柱植入物脊柱内固定系统组件及连接装置的静态及疲劳性能评价方法
  3. YD/T 2827.3-2015 无线通信射频和微波器件无源互调电平测量方法 第3部分:同轴连接器
  4. YD/T 2827.1-2015 无线通信射频和微波器件无源互调电平测量方法 第1部分:通用要求
  5. YY/T 1643-2018 远程医用影像设备的功能性和兼容性检验方法
  6. YD/T 2806-2015 云计算基础设施即服务(laaS)功能要求与架构
  7. YD/T 2331-2011 电信网和互联网服务目录管理技术要求
  8. YDB 162-2015 云服务保障管理技术要求
  9. YDB 144-2014 云计算服务协议参考框架
  10. YDB 143.3-2014 面向政务的云服务 第3部分:云数据库服务要求
  11. YDB 143.2-2014 面向政务的云服务 第2部分:对象存储服务要求
  12. YDB 143.1-2014 面向政务的云服务 第1部分:云主机服务要求
  13. YDB 085.1-2012 近场通信(NFC)安全技术要求 第1部分: NFCIP-1 安全服务和协议
  14. TB/T 2909-1998 机车车辆工艺装备编号方法
  15. HG/T 2871-2008 胶鞋整鞋屈挠试验方法
  16. TB/T 2774-1997 减速顶测试方法
  17. YY/T 1457-2016 无源外科植入物硅凝胶填充乳房植入物中寡聚硅氧烷类物质测定方法
  18. YY/T 0815-2010 差示扫描量热法测定超高分子量聚乙烯熔化焓、结晶度和熔点
  19. YY/T 0810.1-2010/ISO 14879-1 :2000 外科植入物全膝关节假体 第1部分:胫骨托疲劳性
  20. YY/T 0813-2010 交联超高分子量聚乙烯(UHMWPE)分子网状结构参数的原位测定标准方法
调试方法服务service | 软件设计/软件工程 2022-05-02 377 0star收藏 版权: . 保留作者信息 . 禁止商业使用 . 禁止修改作品
在开发Windows服务的时候,调试起来不是很方便,因为这样的程序是没有屏幕的。

一般调试是在服务启动后通过附加进程进行调试,但是服务启动过程中执行的代码不能通过这种方式进行调试。

另外,在服务的启动方法中加入thread.sleep()方法,让它休眠几秒,这样就有时间通过??attach process方法调试服务启动过程中执行的代码。

不过很高兴最近在博客园看到一个问题,里面提到了一个调试服务的方法,非常简单好用,给了我很多帮助。在此,谢谢大哥。



调试方法:

   在服务的 start() 方法中,添加: System.Diagnostics.Debugger.Launch();这段代码。这样在启动服务时会默认打开vs的调试窗口进行调试,

只需要提前设置断点,是不是很方便?

(When developing windows services, debugging is not very convenient, because such programs have no screen.
Generally, debugging is performed through additional processes after service startup, but the code executed during service startup cannot be debugged in this way.
In addition, add thread. In the service startup method Sleep () method, let it sleep for a few seconds, so that it has time to pass?? The attach process method debugs the code executed during service startup.
I'm very glad to see a lot of simple debugging methods mentioned in the blog recently, but I'm very glad to see a good one. Here, thank you, brother.
Commissioning method:
In the start () method of the service, add: system Diagnostics. Debugger. Launch(); This code. In this way, the debugging window of vs will be opened for debugging by default when starting the service,
Is it convenient to set breakpoints in advance?
)





上一篇:回调机制
下一篇:ANDROID UI开发——实现菜单左右