且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过Visual Studio中的不同解决方案进行调试

更新时间:2022-10-21 08:07:58

没有办法让Visual Studio的2个实例调试相同的过程。这是Windows的限制,大多数其他操作系统最多只能调试一个进程。



这是一个完全支持的方案,但是调试不是解决方案一部分的二进制文件。正如你所注意到的那样,从解决方案A调试时,您可以从解决方案B中快乐地进入二进制文件。



一个可以解决方案的项目是调试功能命名为Just My Code。这是一个功能,旨在最大限度地减少调试体验,只需解决方案中的代码。很适合正常的解决方案,但是当你调试任意的二进制文件时,这是很糟糕的。这可能会导致您遇到的突破点的很多问题。您需要通过执行以下操作来禁用它:


  • 工具 - >选项 - >调试

  • 未选中启用我的代码


Currently I have solution A that contains a domain layer base and solution B that references the binaries from solution A. Is there a way to debug straight through from one to the other with two instances of visual studio open (one for each solution). I've read that you can just add the existing projects from solution A to solution B. Is there any other solution that works? I've tried directly attaching solution A to what the running executable in solution B but it won't let me attach multiple debuggers to the same app.

I should note that when I step into a piece of it automatically brings up the code from solution A within solution B's instance of Visual studio to debug in. I suppose this is acceptable, but you can't just set arbitrary breakpoints and wait for the code to hit them this way.

Thanks

There is no way to have 2 instances of Visual Studio debugging the same process. This is a limitation of Windows, and most other operating systems in that at most one process can be debugging another.

It is a perfectly supported scenario though to debug binaries that are not a part of your solution. As you've noted you can happily step into binaries from Solution B while debugging from a Solution A.

One item that will get in the way here though is the Debugging feature named "Just My Code". This is a feature aimed at minimizing the debugging experience to just the code in your solution. Great for normal solutions but bad when you're debugging arbitrary binaries. It's likely causing a lot of the problems around break points you're seeing. You'll want to disable it by doing the following

  • Tools -> Options -> Debugging
  • Unchecked "Enable Just My Code"