Share via


Debugging a managed 64 bit service

I was trying to put a breakpoint in the Main function of a managed process which was being launched by a managed service. I knew about the IFEO (Image file execution option) and I was trying it with vsjitdebugger.exe but it just would not attach. A little web search led me to great blog entries by Mike. The problem was that both the service and the process were not only managed but also 64 bit. Currently, it seems vsjitdebugger.exe does not support this scenario. Anyhow, Mike also has another blog entry where he explains a bit on how managed and native debuggers operate.

But I was still stuck on how to debug the service or the foo.exe launched by the service. The only clean way is to modify our code in the Main function (or OnStart if it is a service) and use Debugger.Launch() (so annoying).

public static void Main()

{

    //you can use #define DEBUG also so that this become debug only code 

    try

    {

      if (!Debugger.IsAttached)

        { 

            Debugger.Launch();

             Debugger.Break();
         }

    }

    catch (Exception ex)

    {

        //log and see which exception was thrown.
 

    } 

    // continue with your main function 

But then I was interested in how things work here.

Q . How does Debugger.Launch() know which debugger to start and where is it listed?

 Ans.