How to debug a C# .NET application in Visual Studio 2010 that is started from another process

后端 未结 3 1480
说谎
说谎 2021-01-05 20:08

I have a .NET GUI application written in C# and a PDF printer. The PDF printer has a field where you can set a command to start an external application.

In this case

3条回答
  •  囚心锁ツ
    2021-01-05 21:08

    Consider adding a call into your code that explicitly requests that the debugger be attached at the current location. This has been around since Win32 days, and surfaces in .NET as System.Diagnostics.Debugger.Break (and System.Diagnostics.Debugger.Launch).

    You can also add logic to decide when to trigger this if you don't want to do it the first time through:

       #if DEBUG
          if (++staticCounter > 3) System.Diagnostics.Debugger.Break();
       #endif
    

    And, of course, you'll want to disable it for production.

提交回复
热议问题