❔ 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
im very nooby when it comes to these things; But i assume it has something to do with args?
you can only have one entrypoint per project.
and entrypoint is...
$mains
The 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 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-lineMain() and command-line arguments
Learn about Main() and command-line arguments. The 'Main' method is the entry point of an executable program.
one of these.
ohhhhh i see
public static void Main(string[] args) { } isnt this the same that im already using?
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.
oooooooooooooooooh now i see it
that method is not related to your problem
i see o_o
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..)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
show me your
Program.cs
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
BlazeBin - arbidrczmcub
A tool for sharing your source code with the world!
i think thats it
do you have any other .cs files in your project?
Like different saved files?
of this particular project?
I mean exactly what I wrote
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
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
oh i see
so all .cs files will be part of the compilation
example:
ohhhh i see; How do i locate that?
this is a project with two code files in it
uhm, you have some kind of code editor open I assume?
use that?
I use Visual Studios
as instructed
... do you really?
VS, or VS Code?
i believe its the latest version
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
This is pretty interesting
theres so many things to consider within this
this is .NET Framework?
why?
Yeah! I havent been instructed to use anything else.
from the first assignment to this
were you actively instructed to use .NET Framework?
Yeah from the very first assignment
okay.
the literature states nothing else too
thats from 2017, and is essentially dead
just so you are aware
ohhh i see
just for my own curiosity; what is the replacement that people use now?
.NET
Also if i use that would it break my program?
specifically .NET 7 is the latest version
I see 😮
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
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
I dont want to see the reference or expanded code view
okay
just like this?
okay, so show me ProgramHelper.cs
yes
theres just one reference there
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?Welllll i can only see one Main in both my code and the ProgramHelper; unless theres another Main Method that isnt called "Main"
they are always called
Main
but you see two of them right?
One in Program, one in ProgramHelperYeah? they're identical
And how many were allowed per project?
You currently have 2.
Only one is allowed
oh
Correct.
So which one am i allowed to delete?
And also
noob question
looks to me like your entire program is contained within
Program.cs
There's two instances hidden there; But i only see one in the actual code
but I have not seen the code for
ProgramHelper
?So within the code itself as i linked above
yes
there's only one main method; Why is it hidden in these sidebars? Does this only apply to Main methods?
??
sidebars?
what are you talking about
hahahaha
okay
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
instances?
Like two different Main methods
You do realize that
ProgramHelper
is a different file right?
its literally two different .cs filesi did not take that into account o_o
Sorry for all the stupid questions lol
so, again, a project is defined by the csproj file
any .cs files within its directory structure will be part of that project implicitly
If i'd like to delete ProgramHelpers completely; How would one go about that?
like within this project
click it, press delete, confirm
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
flawlessly is a strong word :p
Thank you so much yet again; You should become a Teacher if you
you're not already hahaha
Oh?!?!
Eh, I prefer the pay being a software developer gives...
I do not blame you hahaha
woopwoop
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
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)
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.
Thats wildddddd
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
Nono, they have SATs, Exams where the results will factor in if they take you in
okay
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
you mean best case can't resist making stockholm jokes.
Hahahah i mean you're not wrong XD
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.