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