I have an application that has a startup project (ProjectA) that runs another executable in another Project (ProjectB). When I start the solution with ProjectA as the startup project, I am unable to debug ProjectB. It is unable to load the PDB file even though it is in the directory where its searching.
However, when I start the application and ProjectB is the startup project, I am able to debug it. I assume this is because it is referencing the executable instead of the dll.
Why is this so? How do I get around this so that I can have ProjectA be the startup project and still debug ProjectB?
As I understand it, your Project A has started the Project B
.exe. Something along these lines:You want to debug Project B in this context, but your debugger is attached only to Project A and not to Project B:
Manual
The interactive way to go about it is with DEBUG\Attach to Process...
Now you will hit your breakpoints.
Programmatic
Doing this automatically is tricky but possible. Refer to this answer:
Can I programmatically attach a running .NET 6 process to a running instance of Visual Studio debugger?
Suggestion
If Project A doesn't reference Project B directly (that is, they're completely independent inside a common solution where Project A is the startup) I find that it saves a lot of confusion to have Project B build automatically (if needed) whenever Project A runs. Manually setting
project-ato depend onproject-bachieves this outcome.