Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugger not attaching to process

I have an MMC snap-in that I am trying to debug. Currently, the following code, placed in the snap-in's constructor, works in terms of attaching the debugger to it:

public MySnapIn()
{
#if DEBUG
    if (!Debugger.IsAttached)
    {
        Debugger.Launch();
    }
#endif
    ...
}

But its really annoying to always have to attach a debugger to Visual Studio. I want to automate this process. Ideally, I would just have to hit F5 and it automatically attaches the debugger. I have tried the following:

  • Project Properties -> Start external program -> typed in "C:\Windows\System32\mmc.exe"
  • Project Properties -> Command line arguments -> Gave it a path to a .msc file (stores snap-in layout so it makes it easier to load it every time, so that you don't always have to File -> Add/Remove Snap-in).

This didn't work. The debugger won't attach automatically. How can I automate this process, or what's blocking the debugger from attaching automatically?

like image 697
Alexandru Avatar asked Sep 16 '14 15:09

Alexandru


1 Answers

Just got it. As it turns out, you have to use the 32-bit MMC launcher on a 64-bit system (which I am on), and then add the -32 flag to the "Command line arguments" to force it to stay in 32-bit mode:

  • Made sure my snap-in project targeted Any CPU in Configuration Manager.
  • Project Properties -> Start external program -> typed in "C:\Windows\ SysWOW64 \mmc.exe"
  • Project Properties -> Command line arguments -> Gave it a path to a .msc file, and also the -32 flag (stores snap-in layout so it makes it easier to load it every time, so that you don't always have to File -> Add/Remove Snap-in).
like image 163
Alexandru Avatar answered Sep 21 '22 23:09

Alexandru