C
C#•2mo ago
mich4s

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
No description
72 Replies
Angius
Angius•2mo ago
What files do you have in the project? Is there a .csproj file? If so, send it's contents
mich4s
mich4sOP•2mo ago
No description
mich4s
mich4sOP•2mo ago
wdym by contents should i open the csproj file?
Angius
Angius•2mo ago
Yeah It's just a text file
mich4s
mich4sOP•2mo ago
when i opened it my code shows up
No description
Angius
Angius•2mo ago
Open it with Notepad or something
mich4s
mich4sOP•2mo ago
got it
mich4s
mich4sOP•2mo ago
No description
Pobiega
Pobiega•2mo ago
thats a .NET framework project
Angius
Angius•2mo ago
Yeah
mich4s
mich4sOP•2mo ago
No description
Angius
Angius•2mo ago
dotnet CLI works with new versions of .NET This code you can run in Visual Studio
Pobiega
Pobiega•2mo ago
you've accidentally picked the wrong (old, legacy) version when you made your project
mich4s
mich4sOP•2mo ago
huhhhh
Pobiega
Pobiega•2mo ago
$newproject
MODiX
MODiX•2mo ago
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
mich4s
mich4sOP•2mo ago
so i picked the wrong dotnet?
Pobiega
Pobiega•2mo ago
you picked the red option you should use the green option
mich4s
mich4sOP•2mo ago
oh i sure did wait
mich4s
mich4sOP•2mo ago
No description
mich4s
mich4sOP•2mo ago
which one is the good one
Pobiega
Pobiega•2mo ago
top top good, bottom baad
mich4s
mich4sOP•2mo ago
alright
mich4s
mich4sOP•2mo ago
No description
mich4s
mich4sOP•2mo ago
looks good?
Pobiega
Pobiega•2mo ago
you should be able to copy most if not all your code over yes
mich4s
mich4sOP•2mo ago
No description
mich4s
mich4sOP•2mo ago
do not use top-level statements is without the main right
Angius
Angius•2mo ago
The other way
Pobiega
Pobiega•2mo ago
if you check it, you get the main
Angius
Angius•2mo ago
If you check it, you will have the main
mich4s
mich4sOP•2mo ago
uhhh so right now no main
Angius
Angius•2mo ago
ye
mich4s
mich4sOP•2mo ago
and when i click on the box i main okay okay
Pobiega
Pobiega•2mo ago
ya
mich4s
mich4sOP•2mo ago
is there any way to change or modify that when i do the developer powershell it automatically gets me onto desktop?
Angius
Angius•2mo ago
huh?
Pobiega
Pobiega•2mo ago
default start dir? uh yeah you could put a "cd C:\path\to\desktop" in your ps profile
mich4s
mich4sOP•2mo ago
No description
mich4s
mich4sOP•2mo ago
like look i have to do these cd..
Pobiega
Pobiega•2mo ago
or better, use zoxide
mich4s
mich4sOP•2mo ago
idk whats that
Pobiega
Pobiega•2mo ago
mich4s
mich4sOP•2mo ago
where is ps profile
Pobiega
Pobiega•2mo ago
google
Angius
Angius•2mo ago
Why are you trying to run it from the pwsh in the first place? You're using VS Just click the green arrow
mich4s
mich4sOP•2mo ago
idk my teacher told me to do so
Angius
Angius•2mo ago
Then just cd into the correct directory
mich4s
mich4sOP•2mo ago
it works nice
Angius
Angius•2mo ago
Odd that it's not where VS would open the session, though
mich4s
mich4sOP•2mo ago
idk well also a question
mich4s
mich4sOP•2mo ago
No description
mich4s
mich4sOP•2mo ago
No description
mich4s
mich4sOP•2mo ago
why are the folders so weirdly placed like i have to go inside another folder
Pobiega
Pobiega•2mo ago
solution + project its standard
mich4s
mich4sOP•2mo ago
whats a solution
Pobiega
Pobiega•2mo ago
most "real" programs in .NET will have multiple projects a collection of projects the .sln file is your solution file
mich4s
mich4sOP•2mo ago
yeah i see can i run my code with dotnet run using the solution or only .cs
Pobiega
Pobiega•2mo ago
neither dotnet run runs a project not a .cs file and it doesnt run solutions either, as solutions dont have a defined entrypoint
mich4s
mich4sOP•2mo ago
uhhhhhhh so it runs the .csproj file?
Pobiega
Pobiega•2mo ago
kinda it needs the csproj to run
mich4s
mich4sOP•2mo ago
okay im not gonna dig deeper im too dumb for that rn
Pobiega
Pobiega•2mo ago
csproj is the file that declares the project
mich4s
mich4sOP•2mo ago
uh i have another question actually
mich4s
mich4sOP•2mo ago
No description
mich4s
mich4sOP•2mo ago
how to run it from there the green arrow?
Pobiega
Pobiega•2mo ago
you opened a folder, not a project/solution
Angius
Angius•2mo ago
Double-click the .csproj or .sln file to open them in VS Or, when opening VS, you should see a list of all recent projects
mich4s
mich4sOP•2mo ago
okay so i cant just open it when i open .cs file
Angius
Angius•2mo ago
No It's not a project or solution file
mich4s
mich4sOP•2mo ago
okay i guess thats all for now sorry for asking dumb questions 😭 thanks for help
TizzyT
TizzyT•2mo ago
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)
Want results from more Discord servers?
Add your server