.net 如何在windows服务启动前附加到该服务?
我需要调试Windows服务的初始化。我有一个在服务初始化期间调用的方法,但由于它在启动时调用,因此我没有足够的时间使用VisualStudio附加进程。此外,由于服务未启动,它不会出现在VS2010的“附加进程”窗口对话框中 因此,我需要的是在服务启动之前通过附加到它的进程来调试服务。 是否可能?添加或配置设置以切换调试,然后尝试以下操作:.net 如何在windows服务启动前附加到该服务?,.net,visual-studio-2010,windows-services,.net,Visual Studio 2010,Windows Services,我需要调试Windows服务的初始化。我有一个在服务初始化期间调用的方法,但由于它在启动时调用,因此我没有足够的时间使用VisualStudio附加进程。此外,由于服务未启动,它不会出现在VS2010的“附加进程”窗口对话框中 因此,我需要的是在服务启动之前通过附加到它的进程来调试服务。 是否可能?添加或配置设置以切换调试,然后尝试以下操作: protected override void OnStart(string[] args) { if (Settings.Default.Deb
protected override void OnStart(string[] args)
{
if (Settings.Default.DebugApplication)
{
System.Diagnostics.Debugger.Launch();
}
// the rest of the code goes here
}
添加或配置设置以切换调试,然后尝试以下操作:
protected override void OnStart(string[] args)
{
if (Settings.Default.DebugApplication)
{
System.Diagnostics.Debugger.Launch();
}
// the rest of the code goes here
}