How to debug windows service

1) Add such code to the service's entry, static Main() function,

#if DEBUG
            System.Diagnostics.Debugger.Launch();
#endif

2) install your windows service appliation with visual studio command tool. command line as follow:

installUtil.exe <Application's name>

3) Open your windows service source code with visual studio, start your windows service at service tool (you can find it at administrator's tool control panel),
then it will pop-up a dialog ask you if want to debug, select yes, that's ok, you can debug your application.

4) If you have modified your source code, you need uninstall the windows service, build your source code, reinstall agian.
Visual Studio 2022 创建 Windows ATL Service 这是因为我们想在编译 Debug 版本时,输入为控制台,但链接的属性中没有做相应的修改,这个属性影响了我们 Debug 版本的入口函数。当指定编译 Debug 版本时,我们通过 _DEBUG 宏将程序编译为控制台程序,通过RegServer注册服务,然后直接运行服务exe程序,这样通过printf输出的信息,就可以在控制台上显示了。当指定编译 Release 版本时,将程序编译为 Windows 程序,通过 Service 注册服务,通过服务管理器管理服务的运行和停止。 阅读详情

相关推荐

How to debug Windows services

This method is similar to the method that you can use to attach a debugger to a process and then debug a process

How to debug the exception

Introduction No matter you area computer programmer or a user, I think you have seen the dialog to remindyour application is crashed, and remind you to contact application vendor orreport to

飞鹰技术 1257

LVGL高效加载外部Flash图片资源的实现与优化

本文深入探讨了在嵌入式UI开发中,如何为LVGL高效加载外部Flash中的图片资源。针对内部Flash容量不足的痛点,详细解析了LVGL的图片处理原理,并对比了内存映射与流式解码两种主流实现方案。文章重点提供了性能优化技巧与实战避坑指南,旨在帮助开发者实现流畅的图片加载体验,解决SPI Flash读取慢、内存占用高等核心挑战。

t1u2v的博客 469

调试windows服务最简单的方法之一

http://item.jd.com/733388.html using System; using System.Collections.Generic; using System.Linq; using System.ServiceProcess; using System.Text; namespace WindowsService1 { stati...

weixin_30329623的博客 409

使用在UE5中使用AirSim插件Eigen库头文件引用报错,出现报错的解决方式

如图所示,用红线圈出的两条头文件引用会报错,提示无法找到他们,但是可以发现的是,他们的路径书写是没有问题的。在终端中运行时候,会出现如下的报错。

GFCLJY的博客 1010

ENVI5.6 批量处理GF-2/GF-6/GF-7:从安装到融合的完整自动化流程

本文详细介绍了ENVI5.6环境下批量处理GF-2/GF-6/GF-7卫星数据的完整自动化流程,包括环境配置、工具安装、正射校正、图像融合等关键步骤。通过实战案例和优化技巧,帮助用户高效完成高分卫星影像处理,提升工作效率。特别针对GF-6和GF-7的特殊处理要点进行了深入解析。

weixin_42546392的博客 182

How to write XML Web Service

How to write XML Web Service{By 林刚 lirincy@163.com} 1.       install IIS, IIS can be installed from Add/Remove Program from Control Panel and select Windows Component install.2.       instal

飞旋无限 1307

TI AWR2944毫米波雷达开发板开箱:用官方Demo快速上手3D点云与热图生成

本文详细介绍了TI AWR2944毫米波雷达开发板的开箱与实战应用,包括硬件准备、软件开发环境搭建、Demo固件刷写与配置、实时可视化与数据解析等全流程指南。通过官方Demo快速上手3D点云与热图生成,帮助开发者高效掌握毫米波雷达技术在工业检测、智能交通等领域的应用。

weixin_42627853的博客 319

Debug Windows Service Applications

https://docs.microsoft.com/en-us/dotnet/framework/windows-services/how-to-debug-windows-service-applications 转载于:https://www.cnblogs.com/kevin1988/p/9890225.html

weixin_30414155的博客 118

QML从入门到实战 - 完整学习路线

想入门 QML 开发?来 “从零开始学 QML” 专栏,海量源码 + 实战案例 + 大型项目拆解,手把手教你搞定跨平台 UI 设计,小白也能轻松掌握!

BenBierBa的博客 3577

三菱FX5U系列PLC与汇川IT6000系列触摸屏进行MODBUS TCP通信的具体方法

三菱FX5U系列PLC与汇川IT6000系列触摸屏进行MODBUS TCP通信的具体方法

Robot_PLC_HMI_Automation 6529

玩转Windows服务系列——Debug、Release版本的注册和卸载,及其原理

Windows服务Debug版本 注册 Services.exe -regserver 卸载 Services.exe -unregserver Windows服务Release版本 注册 Services.exe -service 卸载 Services.exe -unregserver 原理 Windows服务的Debug、Rel...

dfe30001的博客 367

Loki 分布式日志中心服务

分布式日志中心 Loki + Promtail + Grafana

原名又逢乱世。不要放下学习的脚步,毕竟比天天打牌、钓鱼、打游戏更能从内在充实自己。 2360

How to use VS2012 remote debug Windows Azure Cloud Services

Background: Windows Azure Cloud Services 可以在本地调试,使用Visual Studio 2012 + 模拟器 Emulator。但是模拟器的工作状态和环境和真实的云环境还是有区别的。 所以有些问题,需要远程调试(Remote Debug) Steps: 1、Local :Install IDE Visual Studio 2012 at local...

weixin_30607659的博客 147

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

How to debug Web Services or .Net Remoting Components hosted in IIS in Windows 2003 Server

How to debug Web Services or .Net Remoting Components hosted in IIS in Windows 2003 Server     The previous article, Application Logger Based on .Net Remoting, provides you how to debug .Net Remoting...

weixin_34198881的博客 97

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

how to use mstsclib

First of all, I would like to confirm my understanding of your issue. From your description, I understand that when you have drag and drop a Terminal Services Control on a windows form, a compiler...

weixin_33676492的博客 239

调试windows service的OnStart事件及调试service的一些方法汇总

关于调试windows service, 其实这是一个老生常谈的问题了.    通常的处理办法是, 在service运行后, 在调试器中选择attach to process.    然而这种做法也有一定的局限性, 例如在service启动时的OnStart事件中的代码, 基本上很难调试. 往往当attach到我们的service的时候, 这部分代码已经执行过了. 于是, 有人提出, 可以

jiangxinyu的专栏 1万+

【ANR分析】一篇文章带你读懂Service为什么会ANR?

Service的ANR触发原理,是在启动Service前使用Handler发送一个延时的Message(埋炸弹过程),然后在Service启动完成后remove掉这个Message(拆炸弹过程)。如果在指定的延迟时间内没有remove掉这个Message,那么就会触发ANR(没有在炸弹爆炸前拆掉就会爆炸),弹出AppNotResponding的弹窗,让用户选择是继续等待还是直接退出应用程序。通过源码更深层次的理解ANR是这么产生的,从而在日常开发和实际ANR问题分析时能够游刃有余。

TechMix的博客 972

How to capture the Inbound REST logs and the associated REST Request Body in the Service Now system

Steps to Debug REST API Inbound Calls in Service Now: 1. Make sure the property “glide.rest.debug” is set to true under sys_properties table.2. Get the REST request URL and the user_id of the user with which the REST call is coming to instance.3. Log onto

weixin_47584092的博客 1082
上一篇: 一个舞台剧的小剧本, 希望能博得大家的一笑
下一篇: 注册表操作类 vc++
eteran
博客等级 码龄21年 0粉丝 0原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址