❔ Error CS0017

Im doing a graded assignment and im working on it myself; Im stuck at this one line that is telling me i have more than one entry point
100 Replies
sunny innit
sunny innitOP2y ago
sunny innit
sunny innitOP2y ago
im very nooby when it comes to these things; But i assume it has something to do with args?
Pobiega
Pobiega2y ago
you can only have one entrypoint per project. and entrypoint is... $mains
MODiX
MODiX2y 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 whether args is referenced, the await operator is used and/or an explicit return statement is used. https://docs.microsoft.com/en-US/dotnet/csharp/fundamentals/program-structure/main-command-line
Main() and command-line arguments
Learn about Main() and command-line arguments. The 'Main' method is the entry point of an executable program.
Pobiega
Pobiega2y ago
one of these.
sunny innit
sunny innitOP2y ago
ohhhhh i see public static void Main(string[] args) { } isnt this the same that im already using?
Pobiega
Pobiega2y ago
yes, but it looks like you have more than one or you have one defined entrypoint (the above) and ALSO a top level statement file a top level statement file will act as your entrypoint.
sunny innit
sunny innitOP2y ago
oooooooooooooooooh now i see it
sunny innit
sunny innitOP2y ago
Pobiega
Pobiega2y ago
that method is not related to your problem
sunny innit
sunny innitOP2y ago
i see o_o
Pobiega
Pobiega2y ago
its specifically Main that is the reserved name you should only have one Main method, and it should be in Program.cs alternatively you can use top level statements, but again, keep it only in Program.cs (and dont use TLS as a beginner, it just gets confusing, as you can see..)
sunny innit
sunny innitOP2y ago
Definitely does get confusing; I cannot find another Main within my code; i i'm trying to get a little higher grade for this one as i was feeling overzealous
Pobiega
Pobiega2y ago
show me your Program.cs
sunny innit
sunny innitOP2y ago
i can try posting my full code if you'd like to have a look. Dont give me the answer; Just see if you can see it the error
sunny innit
sunny innitOP2y ago
BlazeBin - arbidrczmcub
A tool for sharing your source code with the world!
sunny innit
sunny innitOP2y ago
i think thats it
Pobiega
Pobiega2y ago
do you have any other .cs files in your project?
sunny innit
sunny innitOP2y ago
Like different saved files? of this particular project?
Pobiega
Pobiega2y ago
I mean exactly what I wrote
sunny innit
sunny innitOP2y ago
I dont think i do o_o I've been building and saving each project separately so i have like 3-4 versions of this at this point
Pobiega
Pobiega2y ago
I sense a misunderstanding of what a project is a project is a folder, with a .csproj file at the root level everything in that folder tree (root and down) is considered part of the project
sunny innit
sunny innitOP2y ago
oh i see
Pobiega
Pobiega2y ago
so all .cs files will be part of the compilation
Pobiega
Pobiega2y ago
example:
sunny innit
sunny innitOP2y ago
ohhhh i see; How do i locate that?
Pobiega
Pobiega2y ago
this is a project with two code files in it uhm, you have some kind of code editor open I assume? use that?
sunny innit
sunny innitOP2y ago
I use Visual Studios as instructed
Pobiega
Pobiega2y ago
... do you really? VS, or VS Code?
sunny innit
sunny innitOP2y ago
i believe its the latest version
sunny innit
sunny innitOP2y ago
Pobiega
Pobiega2y ago
ok this looks like VS ok so that right side panel that you have made tiny make that bigger its the "solution explorer" and a very important part of VS it shows your project tree
sunny innit
sunny innitOP2y ago
sunny innit
sunny innitOP2y ago
This is pretty interesting theres so many things to consider within this
Pobiega
Pobiega2y ago
this is .NET Framework? why?
sunny innit
sunny innitOP2y ago
Yeah! I havent been instructed to use anything else. from the first assignment to this
Pobiega
Pobiega2y ago
were you actively instructed to use .NET Framework?
sunny innit
sunny innitOP2y ago
Yeah from the very first assignment
Pobiega
Pobiega2y ago
okay.
sunny innit
sunny innitOP2y ago
the literature states nothing else too
Pobiega
Pobiega2y ago
thats from 2017, and is essentially dead just so you are aware
sunny innit
sunny innitOP2y ago
ohhh i see just for my own curiosity; what is the replacement that people use now?
Pobiega
Pobiega2y ago
.NET
sunny innit
sunny innitOP2y ago
Also if i use that would it break my program?
Pobiega
Pobiega2y ago
specifically .NET 7 is the latest version
sunny innit
sunny innitOP2y ago
I see 😮
Pobiega
Pobiega2y ago
if your instructor has told you to use framework, you use framework but just be aware that its an old version of everything you'll want to learn the modern stuff asap anyways, if you can minimize the expanded tabs in the solution explorer then show it again
sunny innit
sunny innitOP2y ago
Okay! I'll play around with the new version after all of this. I suspect it'll play an integral role in my future program im taking
Pobiega
Pobiega2y ago
I dont want to see the reference or expanded code view
sunny innit
sunny innitOP2y ago
okay
sunny innit
sunny innitOP2y ago
sunny innit
sunny innitOP2y ago
just like this?
Pobiega
Pobiega2y ago
okay, so show me ProgramHelper.cs yes
sunny innit
sunny innitOP2y ago
sunny innit
sunny innitOP2y ago
theres just one reference there
Pobiega
Pobiega2y ago
quizz time How many Main methods does your project have? How many Main methods does Program.cs contain? How many Main methods does ProgramHelper contain?
sunny innit
sunny innitOP2y ago
Welllll i can only see one Main in both my code and the ProgramHelper; unless theres another Main Method that isnt called "Main"
Pobiega
Pobiega2y ago
they are always called Main but you see two of them right? One in Program, one in ProgramHelper
sunny innit
sunny innitOP2y ago
Yeah? they're identical
Pobiega
Pobiega2y ago
And how many were allowed per project? You currently have 2.
sunny innit
sunny innitOP2y ago
Only one is allowed oh
Pobiega
Pobiega2y ago
Correct.
sunny innit
sunny innitOP2y ago
So which one am i allowed to delete? And also noob question
Pobiega
Pobiega2y ago
looks to me like your entire program is contained within Program.cs
sunny innit
sunny innitOP2y ago
There's two instances hidden there; But i only see one in the actual code
Pobiega
Pobiega2y ago
but I have not seen the code for ProgramHelper ?
sunny innit
sunny innitOP2y ago
So within the code itself as i linked above
Pobiega
Pobiega2y ago
yes
sunny innit
sunny innitOP2y ago
there's only one main method; Why is it hidden in these sidebars? Does this only apply to Main methods?
Pobiega
Pobiega2y ago
?? sidebars? what are you talking about
sunny innit
sunny innitOP2y ago
hahahaha okay
sunny innit
sunny innitOP2y ago
sunny innit
sunny innitOP2y ago
so its only visible in the actual code as presented in the middle there but to the very right; with the "Programhelpers" and whatnot theres two instances
Pobiega
Pobiega2y ago
instances?
sunny innit
sunny innitOP2y ago
Like two different Main methods
Pobiega
Pobiega2y ago
You do realize that ProgramHelperis a different file right? its literally two different .cs files
sunny innit
sunny innitOP2y ago
i did not take that into account o_o
Pobiega
Pobiega2y ago
sunny innit
sunny innitOP2y ago
Sorry for all the stupid questions lol
Pobiega
Pobiega2y ago
so, again, a project is defined by the csproj file any .cs files within its directory structure will be part of that project implicitly
sunny innit
sunny innitOP2y ago
If i'd like to delete ProgramHelpers completely; How would one go about that? like within this project
Pobiega
Pobiega2y ago
click it, press delete, confirm
sunny innit
sunny innitOP2y ago
Finally it worked like a charm; I had to double click the ProgramHelpers, it enclosed the Main method for me and i manually deleted the text there only then it gave me the option to right click and delete it i suspect its how this old version of VS works I believe the code is working flawlessly
Pobiega
Pobiega2y ago
flawlessly is a strong word :p
sunny innit
sunny innitOP2y ago
Thank you so much yet again; You should become a Teacher if you you're not already hahaha Oh?!?!
Pobiega
Pobiega2y ago
Eh, I prefer the pay being a software developer gives...
sunny innit
sunny innitOP2y ago
I do not blame you hahaha
sunny innit
sunny innitOP2y ago
sunny innit
sunny innitOP2y ago
woopwoop
Pobiega
Pobiega2y ago
the code isn't bad, and I honestly don't remember the limitations of .NET Framework these days Im not a big fan of the entire thing being static, but thats not really a big deal for a smaller project I doubt it will affect your grades
sunny innit
sunny innitOP2y ago
Im trying to push for an A or a B; not that i need it. I have some exams coming up next month to qualify for Yrkeshögskolan and i'd like to; well... qualify I've no idea how many people they take in; But i joined an intro for the application process of the school; And there were well over 500 people in there :x (within the Teams call)
Pobiega
Pobiega2y ago
Well, if my personal experience is anything to go by, when I went to uni we were 40 people who started. After 4 weeks there were around 25 left. At the end of the term, 18 or so. 4 people graduated.
sunny innit
sunny innitOP2y ago
Thats wildddddd
Pobiega
Pobiega2y ago
there were no interviews, no sample projects, just grades and HP iirc YH usually do interviews? which will filter out a lot of the people who would drop out the first weeks
sunny innit
sunny innitOP2y ago
Nono, they have SATs, Exams where the results will factor in if they take you in
Pobiega
Pobiega2y ago
okay
sunny innit
sunny innitOP2y ago
At least the four places here in Stockholm that i've checked out Worst case scenario i may have to leave the city but we'll see what happens
Pobiega
Pobiega2y ago
you mean best case kekw can't resist making stockholm jokes.
sunny innit
sunny innitOP2y ago
Hahahah i mean you're not wrong XD
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server