❔ New to C#: Cant press F5 to debug in Visual Studio Code

I'm trying to debug C# using F5 but it doesnt respond
69 Replies
Dang Quynh Chi - PM Gr 3 + 4
Any help is appreciated
Philémon
Philémon16mo ago
Hmm, your c# class file is called prgram ? not program ? Can i see the file structure of the project or solution? Also, did you add Visual studio code extensions ? Like C# and C# Dev Kit ?
Dang Quynh Chi - PM Gr 3 + 4
ah yes I did I installed and reinstalled it I'll show you my files
Philémon
Philémon16mo ago
The problem is probably that you have more than one Main method
Philémon
Philémon16mo ago
You need to only have one main method, its the entry point of the application If you want to have more methods, you can make more methods named other than Main, and you can make more classes other than Program
Dang Quynh Chi - PM Gr 3 + 4
I am fairly new to this
Dang Quynh Chi - PM Gr 3 + 4
So I am supposed to fix this file?
Dang Quynh Chi - PM Gr 3 + 4
This is myn other file, I am fairly new to the concept of a Main method. Could I kindly ask you assistance in a solution for this? Thanks for your time : )
Philémon
Philémon16mo ago
No worries, i will help you the best i can I am curious because i see your programMethod class but usually there is already a Program class created when you create a new project. Did you delete or rename this "Program" class file ?
Dang Quynh Chi - PM Gr 3 + 4
Ohh maybe it is because of this file that I downloaded
Dang Quynh Chi - PM Gr 3 + 4
it is the source code for the lessons I am learning I am learning intermediate C# : ") prob a bad idea bc I only am skilled in Ruby
Philémon
Philémon16mo ago
I am a bit confused because you show me file structures ok but it doesnt seem to be the same as the files i see in your first VSCode screenshot With "Learn" and COS20007
Dang Quynh Chi - PM Gr 3 + 4
Oh those are 2 different files I am sorry
Philémon
Philémon16mo ago
So, when you are in this folder "learn", you open with VSCode, right ?
Dang Quynh Chi - PM Gr 3 + 4
OH it was bc of the test file yes!
Philémon
Philémon16mo ago
Is there a Main also in the test files ?
Dang Quynh Chi - PM Gr 3 + 4
yes there was I deleted it and there is no error now however, I cant use ctrl + F5 I've tried to google search but nothing comes up? I know this is super common but I've been struck for a day now
Philémon
Philémon16mo ago
your "learn" folder, you downloaded it like it is from your teacher or something like that, right ?
Dang Quynh Chi - PM Gr 3 + 4
yes it is ah let me convert this into video format
Philémon
Philémon16mo ago
What is the error that you get now? still about entry point?
Dang Quynh Chi - PM Gr 3 + 4
There is no9 error They gave me a selection
SinFluxx
SinFluxx16mo ago
you probably need to update the launch.json file that's opened up
Dang Quynh Chi - PM Gr 3 + 4
of .NET to use, I chose .NET
SinFluxx
SinFluxx16mo ago
SinFluxx
SinFluxx16mo ago
should start off like that
SinFluxx
SinFluxx16mo ago
if you press ctrl + space while your cursor is inbetween the [], it will give you options
Dang Quynh Chi - PM Gr 3 + 4
got it!
SinFluxx
SinFluxx16mo ago
hmm should be a list of suggestions like this:
Dang Quynh Chi - PM Gr 3 + 4
wait nvm earlier I accidently typed '2'
Dang Quynh Chi - PM Gr 3 + 4
so which should I select?
SinFluxx
SinFluxx16mo ago
It's just a Console app you're working on at the moment?
Dang Quynh Chi - PM Gr 3 + 4
yep I just want to see it debug
SinFluxx
SinFluxx16mo ago
should just be that one then
SinFluxx
SinFluxx16mo ago
change this line too:
SinFluxx
SinFluxx16mo ago
SinFluxx
SinFluxx16mo ago
fingers crossed should work now
Dang Quynh Chi - PM Gr 3 + 4
Does this count as debugging?
Philémon
Philémon16mo ago
And the "Problems" tab ?
Dang Quynh Chi - PM Gr 3 + 4
I saw the instructor has a "watch" window open, does that come w vs code?
Philémon
Philémon16mo ago
I think this is beyond my knowledge of visual studio code 😅 But maybe you could try to specify the Path to your program file ? in the launch.json This seems to indicate that for some reason, the path is not valid
Dang Quynh Chi - PM Gr 3 + 4
hmm but usually this is how debugging looks like w C# rigght?
Dang Quynh Chi - PM Gr 3 + 4
I've rarely used debug bc I've only learned Ruby
Philémon
Philémon16mo ago
Oh yes, seems like it ran try some breakpoints and see if it stops there Idk, if you want to learn C# as beginner i think you could consider installing Visual studio 2022 community VSCode is not so beginner friendly atm. Its better than before, but not as good as Visual studio, speaking of first experience
Dang Quynh Chi - PM Gr 3 + 4
yeah I think so too ok the breakpoiint worked! thanks : D
SinFluxx
SinFluxx16mo ago
yeah it's nice and lightweight, but doesn't give you a lot of the features/guidance Visual Studio does
Philémon
Philémon16mo ago
Very nice!
Dang Quynh Chi - PM Gr 3 + 4
thank you again SinFluxx and catpog
Accord
Accord16mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server