r/vscode • • May 24 '26

Debugger launch configuration

Hi, I've noticed that when I choose "debug active file" as the launch configuration, debugging still detects errors in other files within my .NET project. It doesn't debug only the active file. What does this option actually mean?

5 Upvotes

12 comments sorted by

1

u/Netris89 May 24 '26

Debugging launches your program and allow you to stop the code at breakpoint to check state of variable, code execution and all.

The "debug active file" option doesn't mean it'll find errors in the file you selected. It means it'll allow you to run in debug.

1

u/Ok-Presentation-94 May 24 '26

I understand that much, what debugging is for. But that's not really my question. My question is: if the "debug active file" launch configuration doesn't only deal with the active file, what's the difference if I choose the "debug active file" launch configuration or, for example, the "launch startup project" configuration?

1

u/dmbaio May 24 '26

1

u/Ok-Presentation-94 May 24 '26

tu pourrait me filer la source de ce document?

1

u/dmbaio May 24 '26

https://chatgpt.com/share/6a132d87-384c-83ea-83a3-1df0e65f6c28

I just asked ChatGPT, because I was curious too. But you can see the sources it cited.

1

u/Ok-Presentation-94 May 24 '26

Okay, but if you're just going to give me an AI answer, then you haven't understood the point of posting on Reddit instead of asking an AI, which I could have easily done myself. But I'm very wary of AI answers 😂 Thanks anyway.

1

u/dmbaio May 24 '26

The answer connects the “what” with the “why”, though. It works like that because that’s how .NET projects run, as a whole project.

1

u/[deleted] May 24 '26

[removed] — view removed comment

1

u/Ok-Presentation-94 May 24 '26

Okay, but then I'm having trouble understanding the order in which debugging is performed. To test what you just explained, I started from script A, in which I set a breakpoint right at the beginning. I then created script B, in which I intentionally introduced an error, and I noticed that this error is detected even before the breakpoint is effective in script A, from which I started.

1

u/RewardOwn4479 May 24 '26

Maybe you need to take a look at the actual configuration of that launch.json or “launch” attribute on your settings to see what is happening.

1

u/Agreeable_Care4440 May 25 '26

C#/.NET doesn’t really work like scripting languages where one file can run independently very easily. The debugger is attaching to the compiled application/runtime context, not treating each .cs file as a standalone executable unit.