C
C#ā€¢10mo ago
InfinityShadow20

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
No description
129 Replies
Pobiega
Pobiegaā€¢10mo ago
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
MODiX
MODiXā€¢10mo ago
.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.
Pobiega
Pobiegaā€¢10mo ago
so when creating a new project in visual studio, make sure to NOT pick a framework version: $newproject
MODiX
MODiXā€¢10mo 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
Pobiega
Pobiegaā€¢10mo ago
@InfinityShadow20
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
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)??
Pobiega
Pobiegaā€¢10mo ago
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
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
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?
Pobiega
Pobiegaā€¢10mo ago
sure but only the .cs files
Burrito
Burritoā€¢10mo ago
You 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.
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
yeah im not gonna lie to you, even that seems a little to complicated for me šŸ¤£
Pobiega
Pobiegaā€¢10mo ago
its just copying a few files, its pretty much the most basic computer operation you can do
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
ok ill try that first then, just gotta creat a new project first how would I find the .cs files?
Pobiega
Pobiegaā€¢10mo ago
open up your project folder like, I hope you know that your project is just a bunch of files somewhere on your harddrive?
Pobiega
Pobiegaā€¢10mo ago
here is a screenshot from a brand new .net 8 console project:
No description
Pobiega
Pobiegaā€¢10mo ago
you'd copy only the "program.cs" file from there
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
I don't really see a .cs file in there
No description
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
I looked in all the files and nothing came up
Pobiega
Pobiegaā€¢10mo ago
I dont think thats the right folder then
Burrito
Burritoā€¢10mo ago
How did you create your old project?
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
I believe its this one
No description
Pobiega
Pobiegaā€¢10mo ago
wanna jump on a voice channel and share your screen? perhaps I can help you find your files and get the "upgrade" done šŸ™‚
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
Knowing myself Its late for me atm, Its currently nearly 1am and I got work soon
Pobiega
Pobiegaā€¢10mo ago
alr I think VS has a rightclick menu option for "open folder in file explorer"
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
But yeah I believe that I clicked on this one and well... thats the project
Pobiega
Pobiegaā€¢10mo ago
if you click on a project in your solution explorer
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
No description
Pobiega
Pobiegaā€¢10mo ago
nah you gotta open the project first well, or Copy Path that'd work too
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
copied
Pobiega
Pobiegaā€¢10mo ago
then go to a file explorer and paste that into the location bar
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
and now I pasted it but its pretty much giving me only the option to open in vs
Pobiega
Pobiegaā€¢10mo ago
No description
Pobiega
Pobiegaā€¢10mo ago
paste there
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
No description
Pobiega
Pobiegaā€¢10mo ago
nah that aint right
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
šŸ¤·ā€ā™‚ļø
Pobiega
Pobiegaā€¢10mo ago
did your path go directly to the solution file? paste it here
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
yes... its a .slm file apparently... at the end it said .slm
Pobiega
Pobiegaā€¢10mo ago
ok, so remove the last "segment" ie, if it ends with bla\bla\hello.sln then remove hello.sln
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
uh-ha?
No description
Pobiega
Pobiegaā€¢10mo ago
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 over
Zerraq
Zerraqā€¢10mo ago
just copy the Program.cs :D into your new project that u will create (.NET)
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
ok, So I paste that into my new project file?
Pobiega
Pobiegaā€¢10mo ago
into your new project folder
Zerraq
Zerraqā€¢10mo ago
Yeah open your new project the same way like you did now and replace the "program.cs" with the one from your old project
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
And if I remember correctly, its one of the ones that say "yes"?
Pobiega
Pobiegaā€¢10mo ago
yeah, the console one
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
Thats what I meant šŸ˜†
Zerraq
Zerraqā€¢10mo ago
Its a console app right? just pick the one with "Yes"
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
ok one momento
Zerraq
Zerraqā€¢10mo ago
After you created the new Project. Open it exactly like this here! And replace your program.cs with the one from your old project.
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
wait, do I select this one?
No description
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
Console App?
Pobiega
Pobiegaā€¢10mo ago
probably, but I'd feel safer if you found it on the right Change the "desktop" dropdown
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
this one?
No description
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
like the top one ?
Pobiega
Pobiegaā€¢10mo ago
there we go ye
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
what? Its not pasting into the new folder... hmm... just the Program.cs file right?
Pobiega
Pobiegaā€¢10mo ago
ye
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
wierd that its not letting me copy and paste it into the new folder its like as if its an blocked file or something...
Pobiega
Pobiegaā€¢10mo ago
Not sure this helps, but its definitely a user error šŸ™‚
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
hmm... might have to try it the other way
Pobiega
Pobiegaā€¢10mo ago
Do it via file Explorer with no visual Studio instances running
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
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! šŸ™‚
Pobiega
Pobiegaā€¢10mo ago
to be fair, copying a single file should be a 10 sec thing šŸ˜›
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
true but now to try to figure out another issue that just arrived...
Zerraq
Zerraqā€¢10mo ago
what happened :D
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
I have a slight feeling this should be somehow easier to fix than the last one
No description
Zerraq
Zerraqā€¢10mo ago
show me your code where the error comes
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
like the line??
Pobiega
Pobiegaā€¢10mo ago
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 Mains
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
It said that in the last project to.. šŸ¤·ā€ā™‚ļø
Pobiega
Pobiegaā€¢10mo ago
oh lol then you dont have a Main method :p easy as that $mains
MODiX
MODiXā€¢10mo ago
The possible signatures for Main are
public static void Main() { }
public static int Main() { }
public static void Main(string[] args) { }
public static int Main(string[] args) { }
public static async Task Main() { }
public static async Task<int> Main() { }
public static async Task Main(string[] args) { }
public static async Task<int> Main(string[] args) { }
public static void Main() { }
public static int Main() { }
public static void Main(string[] args) { }
public static int Main(string[] args) { }
public static async Task Main() { }
public static async Task<int> Main() { }
public static async Task Main(string[] args) { }
public static async Task<int> Main(string[] args) { }
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-line
Main() and command-line arguments - C#
Learn about Main() and command-line arguments. The 'Main' method is the entry point of an executable program.
Pobiega
Pobiegaā€¢10mo ago
you MUST have exactly one of these methods
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
This is what I have...
No description
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
maybe re-build the solution? I tried that not long ago but I can try again
Pobiega
Pobiegaā€¢10mo ago
that looks fine at a very limited glance
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
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
Pobiega
Pobiegaā€¢10mo ago
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
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
this is what I have for the first few line
No description
Pobiega
Pobiegaā€¢10mo ago
yeah thats fine
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
the error?
Pobiega
Pobiegaā€¢10mo ago
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?
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
No description
Pobiega
Pobiegaā€¢10mo ago
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?
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
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
Pobiega
Pobiegaā€¢10mo ago
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.
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
wait, so If its placed in the wrong place, I can try to fix that by moving it around then trying it again...
SinFluxx
SinFluxxā€¢10mo ago
The screenshot does actually have the answer
Pobiega
Pobiegaā€¢10mo ago
I'd not recommend moving it blindly
SinFluxx
SinFluxxā€¢10mo ago
The local function 'Main' is declared but never used
Pobiega
Pobiegaā€¢10mo ago
ah so your main is inside another method thats.. not allowed
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
so moving it is the way to go??
SinFluxx
SinFluxxā€¢10mo ago
You must have something like:
internal class Program
{
void Test()
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
}
internal class Program
{
void Test()
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
}
And it should be something like:
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}

void Test()
{

}
}
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}

void Test()
{

}
}
Pobiega
Pobiegaā€¢10mo ago
Yes, but truth be told I don't trust you to move it correctly :p
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
Why?
Pobiega
Pobiegaā€¢10mo ago
This thread?
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
As I was talking about moving it, I was thinking "What if I move it to somewhere like there?"
Pobiega
Pobiegaā€¢10mo ago
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
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
I do other things most the time, yes I am VERY new to programing but computers in general??
Zerraq
Zerraqā€¢10mo ago
@InfinityShadow20 do you have time later?, we can hop on a call and i can show you and explain
Pobiega
Pobiegaā€¢10mo ago
Not trying to put you down here, but you didn't know how to copy a file ĀÆ\_(惄)_/ĀÆ
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
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"
Pobiega
Pobiegaā€¢10mo ago
sure given what SinFluxx posted above, do you think you can move it out to the top-level scope of Program? if so, go ahead
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
At 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.
Pobiega
Pobiegaā€¢10mo ago
Relax, there is no beef here.
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
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?
Zerraq
Zerraqā€¢10mo ago
4pm
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
its 2:09Am right now for me so not sure what time it should be for you by about 6pm for me
Zerraq
Zerraqā€¢10mo ago
what day is it for ya
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
Thursday
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
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"...
No description
Pobiega
Pobiegaā€¢10mo ago
I see no static void Main there
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
yeah because the solution told me to getr rid of it + anything thats below it
Pobiega
Pobiegaā€¢10mo ago
go ahead and try and build your project :p it won't work
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
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...
Pobiega
Pobiegaā€¢10mo ago
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
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
well then, where would you put it?
Pobiega
Pobiegaā€¢10mo ago
in Program but not inside another method that was your issue before you somehow placed it inside another method, turning it into a local method
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
No description
Pobiega
Pobiegaā€¢10mo ago
yep gotta give it a body too
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
what? how?
Pobiega
Pobiegaā€¢10mo ago
{}
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
Whats a body?
Pobiega
Pobiegaā€¢10mo ago
No description
Pobiega
Pobiegaā€¢10mo ago
non-abstract methods must have a body, even if its just an empty one
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
Shift + Enter seems to have done it...
No description
InfinityShadow20
InfinityShadow20OPā€¢10mo ago
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"?
Want results from more Discord servers?
Add your server