Visual Studio中断时,我的C#服务在哪里? [英] where is my C# service when Visual Studio breaks?

查看:87
本文介绍了Visual Studio中断时,我的C#服务在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我是C#编程的新手,并且有一个非常基本的问题.
在代码运行时,我熟悉的大多数调试器/仿真器
然后您破坏"调试器,调试器通常会向您确切显示
代码正在运行.

当我为Windows服务执行此操作时,似乎不是这种情况.
它总是使我回到早期:

ServiceBase.Run(ServicesToRun);

有什么方法可以查看堆栈和/或确切的指令(最好是
源代码行)当我中断时它在哪里运行?

谢谢,

Mitch

Hello all,

I am somewhat new to C# programming, and have a very basic question.
In most debuggers/emulators I am familiar with, when the code is running
and you "break" the debugger, the debugger usually shows you exactly where
the code was running.

This does not seem to be the case when I do this for my Windows service.
It always takes me back to an early point:

ServiceBase.Run(ServicesToRun);

Is there any way to see the stack and/or the exact instruction (preferably
source code line) where it is running when I break?

Thanks,

Mitch

推荐答案

是的,有视图堆栈选项.

此处 [
Yes there is a view stack option.

Here[^] is more information on this window.


如果进程在消息中循环等待状态,您通常会得到像这样的无用断点(或WinForms应用程序中的Application.Run).如果服务在其主线程上并未真正执行任何操作(并且并非大多数时间都在服务中),则将其断开即可.如果要在有用的地方停下来,请在一些功能代码中添加断点.
If the process is in a message loop wait state, you will often get a useless breakpoint like this (or Application.Run in WinForms apps). If the service is not really doing anything on its primary thread (and a service is not most of the time), breaking it will do this. Put a breakpoint in some functional code if you want to get a stop in a useful place.


这篇关于Visual Studio中断时,我的C#服务在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆