Switching language Versions:
Hey Everyone, So I was trying to make my first ever text based game and all was going well until I got the error you can see in the ss below.
I just updated to the latest version in the VS Installer less than 1 hour ago and Im not sure how to fix this issue.
According to what it says here, I currently have v 7.3 and need v 8.0 or higher for this bit of the code to work.
Is there an easy way to fix this?
Thank you in advance,
- InfinityShadow20
129 Replies
It sounds very likely that you made a .NET Framework project, instead of a .NET project
now this might sound confusing, so I'll just ask the bot to post a description: $net
$.net
.NET is a marketing term referring to a family of products, consisting of two different lineages.
The .NET Framework ("netfx") lineage was introduced in 2002. This lineage runs only on Windows. Its most recent release is .NET Framework 4.8.1. While this lineage is still supported, very few new features are being introduced into it. Devs are encouraged not to target .NET Framework for new app development.
The .NET Core ("netcore") lineage was introduced in 2016. This is a modern development platform which runs across many different OSes. The .NET Core 3.1 product was the last version in this lineage to bear the ".NET Core" name; and starting with the next release (.NET 5), the product was renamed to simply ".NET".
.net6
in 2021, .net7
in 2022, .net8
in 2023 ... in this lineage is .NET 7. This lineage is where new features are actively being developed. Devs are encouraged to target .NET for new app development.
Nowadays, the ".NET" moniker usually refers to recent versions of the netcore lineage. When you create a new app targeting .NET (not .NET Framework!), you're targeting this newer, modern, cross-platform API surface and runtime.so when creating a new project in visual studio, make sure to NOT pick a framework version: $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
@InfinityShadow20
so basically, there is no way to fix it and I have to basically start from scratch on a new project that doesn't have (.NET Framework)??
you don't have to "start from scratch"
most of your code can be copied right over
just make a new console project, then copy over all your code files, and try to run it
fix errors as they pop up
well yeah, I meant like, basically copy everything over to like notepad or something, close and maybe delete the current project then start a new one and paste the code into into the new project and hopefully fix the issues...
copy the files from File Explorer?
sure
but only the
.cs
filesYou don't have to use notepad as a middle man, you can just make a new project in a new folder, and copy over the
.cs
files from your old project.yeah im not gonna lie to you, even that seems a little to complicated for me š¤£
its just copying a few files, its pretty much the most basic computer operation you can do
ok ill try that first then, just gotta creat a new project first
how would I find the .cs files?
open up your project folder
like, I hope you know that your project is just a bunch of files somewhere on your harddrive?
here is a screenshot from a brand new .net 8 console project:
you'd copy only the "program.cs" file from there
I don't really see a .cs file in there
I looked in all the files and nothing came up
I dont think thats the right folder then
How did you create your old project?
I believe its this one
wanna jump on a voice channel and share your screen? perhaps I can help you find your files and get the "upgrade" done š
Knowing myself
Its late for me atm, Its currently nearly 1am and I got work soon
alr
I think VS has a rightclick menu option for "open folder in file explorer"
But yeah I believe that I clicked on this one and well... thats the project
if you click on a project in your solution explorer
nah you gotta open the project first
well, or
Copy Path
that'd work toocopied
then go to a file explorer and paste that into the location bar
and now I pasted it but its pretty much giving me only the option to open in vs
paste there
nah
that aint right
š¤·āāļø
did your path go directly to the solution file?
paste it here
yes... its a .slm file apparently...
at the end it said .slm
ok, so remove the last "segment"
ie, if it ends with
bla\bla\hello.sln
then remove hello.sln
uh-ha?
there we go
and all your code is in a single file too
that makes life very easy for you right now
just copy
Program.cs
overjust copy the Program.cs :D
into your new project that u will create (.NET)
ok, So I paste that into my new project file?
into your new project folder
Yeah open your new project the same way
like you did now
and replace the "program.cs" with the one from your old project
And if I remember correctly, its one of the ones that say "yes"?
yeah, the console one
Thats what I meant š
Its a console app right? just pick the one with "Yes"
ok one momento
After you created the new Project. Open it exactly like this here!
And replace your program.cs with the one from your old project.
wait, do I select this one?
Console App?
probably, but I'd feel safer if you found it on the right
Change the "desktop" dropdown
this one?
like the top one
?
there we go
ye
what? Its not pasting into the new folder...
hmm...
just the Program.cs file right?
ye
wierd that its not letting me copy and paste it into the new folder
its like as if its an blocked file or something...
Not sure this helps, but its definitely a user error š
hmm... might have to try it the other way
Do it via file Explorer with no visual Studio instances running
ok
ok it seems to have finally worked, I had to close vs down but I kept the file explorer up and went to where the other new project is and saw that it was already there though I guess it was just invisible?
Anyways, It seems to all be here, thank you all for your help!
Can't believe it was that much trouble for one error! š¤£
and I mean it, Thank you all!
š
to be fair, copying a single file should be a 10 sec thing š
true
but now to try to figure out another issue that just arrived...
what happened :D
I have a slight feeling this should be somehow easier to fix than the last one
show me your code
where the error comes
like the line??
eh, are you sure the files copied over correctly? that error indicates that your project doesnt contain a valid
Main
method
and what is a valid main method hasnt changed, all valid Framework Mains are valid .NET MainsIt said that in the last project to.. š¤·āāļø
oh lol
then you dont have a
Main
method :p
easy as that
$mainsThe possible signatures for
Main
are public
is not required (can be any accessibility).
Top-level statements are compiled into a Main
method and will use an appropriate signature depending on the body.
https://docs.microsoft.com/en-US/dotnet/csharp/fundamentals/program-structure/main-command-lineMain() and command-line arguments - C#
Learn about Main() and command-line arguments. The 'Main' method is the entry point of an executable program.
you MUST have exactly one of these methods
This is what I have...
maybe re-build the solution?
I tried that not long ago but I can try again
that looks fine
at a very limited glance
I mean... There isn't really much else to look at, the rest is just a story which personally Im not to to comfortable with sharing...
but the weird thing is, that static void thing is on line 22, the error is on line 1
nah
the error doesnt have a location
the error is "your project doesnt contain the mandatory thing I need"
how do you specify WHERE that is?
:p
this is what I have for the first few line
yeah thats fine
the error?
well imagine you're the compiler
you get handed ~100 lines of code
you look through them for the thing you need, but its not there
at what line do you say the error is?
you're not understanding
its an error without a location
the error is that something is missing
how would you specify where that something is missing from?
im sorry, its been quite a little while since Ive last been on this project, and not to mention my disability that I forget a lot of things...
Im not sure
its not a question for you lol
its.. nevermind
anyway, your problem is that the compiler doesnt agree that you have a valid main
as far as I can tell, you do, but you also only showed part of a single line
so I can't tell if its placed wrong, or has an invalid namespace etc
So either you figure it out on your own, or you find a way to share the code without your story that you don't want to share.
wait, so If its placed in the wrong place, I can try to fix that by moving it around then trying it again...
The screenshot does actually have the answer
I'd not recommend moving it blindly
The local function 'Main' is declared but never used
ah
so your main is inside another method
thats.. not allowed
so moving it is the way to go??
You must have something like:
And it should be something like:
Yes, but truth be told I don't trust you to move it correctly :p
Why?
This thread?
As I was talking about moving it, I was thinking "What if I move it to somewhere like there?"
Its very obvious you are very very new to programming and maybe computers in general
And thats fine ofc, but "just move the method" can result in many different results
I do other things most the time, yes I am VERY new to programing but computers in general??
@InfinityShadow20 do you have time later?, we can hop on a call
and i can show you and explain
Not trying to put you down here, but you didn't know how to copy a file
ĀÆ\_(ć)_/ĀÆ
Well it was either risk it and see what happens or don't do anything at all and pretty much never end up fixing the thing... I can always undo what ever with "Ctrl + Z"
sure
given what SinFluxx posted above, do you think you can move it out to the top-level scope of
Program
?
if so, go aheadAt first I wasn't sure about it, secondly, having just do it the other way I explained before seemed much simpler to me. Thirdly, The file was apparently "invisible" so I couldn't see it until I reloaded thefile explorer.
Relax, there is no beef here.
Ok sorry
im just very tired right now, a little stressed out etc
yeah sometime tomorrow (Well techinically today) Don't know when the best time is though, What time is it for you right now?
4pm
its 2:09Am right now for me so not sure what time it should be for you by about 6pm for me
what day is it for ya
Thursday
well, On one hand, I was able to fix the issue using the solution thing...
However, It made me pretty much have to get rid of the entire story so now Im back to just the... "Bare Bones"...
I see no
static void Main
thereyeah because the solution told me to getr rid of it + anything thats below it
go ahead and try and build your project :p
it won't work
oh and btw I did move it around a bit and I was able to get rid of that error but the "unused" thing was still there
I wasn't really gonna do that yet, + I think I might have to clear it first then re-build it
I did want to get some sort of story down first, even just a few sentences...
compiling your project isnt a "Im ready to release" thing
its a sanity check to make sure you didnt break anything
in this case, you have removed the mandatory main method
well then, where would you put it?
in
Program
but not inside another method
that was your issue before
you somehow placed it inside another method, turning it into a local methodyep
gotta give it a body too
what?
how?
{}
Whats a body?
non-abstract methods must have a body, even if its just an empty one
Shift + Enter seems to have done it...
Anyone know if and where I can find this "Set-up" thing in the solution tab to add to my first ever "Text based Game"?