Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 如何在windows服务启动前附加到该服务?_.net_Visual Studio 2010_Windows Services - Fatal编程技术网

.net 如何在windows服务启动前附加到该服务?

.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

我需要调试Windows服务的初始化。我有一个在服务初始化期间调用的方法,但由于它在启动时调用,因此我没有足够的时间使用VisualStudio附加进程。此外,由于服务未启动,它不会出现在VS2010的“附加进程”窗口对话框中

因此,我需要的是在服务启动之前通过附加到它的进程来调试服务。 是否可能?

添加或配置设置以切换调试,然后尝试以下操作:

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
}