【发布时间】:2012-04-25 07:37:31
【问题描述】:
当我使用VS2010 SP1时,我编写了一个windows服务。现在我想调试它而不安装它。所以我在 Program.cs 的 main 方法中编写代码如下:
#if (DEBUG)
ControllerNTService service =new ControllerNTService();
Console.ReadLine();
#else
System.ServiceProcess.ServiceBase[] ServicesToRun;
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new ControllerNTService() };
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
#endif
我希望在 VS 2010 中调试 windows 服务。但是在 VS 中,下面的代码行显示为灰色。这意味着格雷码无效,对吗? (两条线是灰色的)
ControllerNTService service =new ControllerNTService();
Console.ReadLine();
如果代码有效,我想我可以遇到它们。
另外一个问题,使用上面的代码,当我按F5调试它时,它显示它无法调试它,我需要先安装服务。
我希望有人遇到类似的问题来指导我。 祝你有美好的一天
【问题讨论】:
标签: c# visual-studio-2010 debugging windows-services