i cant run my code and i dont know what to do
exactly as i stated, i dont know im new to c# and it worked in class but doesnt work in home, thanks for help
72 Replies
What files do you have in the project?
Is there a
.csproj
file?
If so, send it's contentswdym by contents
should i open the csproj file?
Yeah
It's just a text file
when i opened it my code shows up
Open it with Notepad or something
got it
thats a .NET framework project
Yeah
dotnet
CLI works with new versions of .NET
This code you can run in Visual Studioyou've accidentally picked the wrong (old, legacy) version when you made your project
huhhhh
$newproject
When creating a new project, prefer using .NET over .NET Framework, unless you have a very specific reason to be using .NET Framework.
.NET Framework is now legacy code and only get security fix updates, it no longer gets new features and is not recommended.
https://cdn.discordapp.com/attachments/569261465463160900/899381236617855016/unknown.png
so i picked the wrong dotnet?
you picked the red option
you should use the green option
oh i sure did
wait
which one
is the good one
top
top good, bottom baad
alright
looks good?
you should be able to copy most if not all your code over
yes
do not use top-level statements is without the main right
The other way
if you check it, you get the main
If you check it, you will have the main
uhhh
so right now
no main
ye
and when i click on the box
i main
okay okay
ya
is there any way to change or modify that when i do the developer powershell it automatically gets me onto desktop?
huh?
default start dir? uh yeah
you could put a "cd C:\path\to\desktop" in your ps profile
like look
i have to do these cd..
or better, use zoxide
idk whats that
where is ps profile
google
Why are you trying to run it from the pwsh in the first place?
You're using VS
Just click the green arrow
idk my teacher told me to do so
Then just
cd
into the correct directoryit works
nice
Odd that it's not where VS would open the session, though
idk
well also a question
why are the folders so weirdly placed
like
i have to go inside another folder
solution + project
its standard
whats a solution
most "real" programs in .NET will have multiple projects
a collection of projects
the
.sln
file is your solution fileyeah i see
can i run my code with dotnet run using the solution
or only .cs
neither
dotnet run
runs a project
not a .cs file
and it doesnt run solutions either, as solutions dont have a defined entrypointuhhhhhhh
so it runs the .csproj
file?
kinda
it needs the csproj to run
okay im not gonna dig deeper
im too dumb for that rn
csproj is the file that declares the project
uh i have another question actually
how to run it from there
the green arrow?
you opened a folder, not a project/solution
Double-click the
.csproj
or .sln
file to open them in VS
Or, when opening VS, you should see a list of all recent projectsokay
so i cant just open it
when i open .cs
file
No
It's not a project or solution file
okay
i guess thats all for now
sorry for asking dumb questions ðŸ˜
thanks for help
I think originally, just right clicking the project (not solution) in solution explorer and "Set as Startup Project"?
going on this image btw
in dotnet cli there is an option to specify the project aswell (the .csproj)