C
C#15mo ago
sunny innit

❔ 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 innit15mo ago
sunny innit
sunny innit15mo ago
im very nooby when it comes to these things; But i assume it has something to do with args?
Pobiega
Pobiega15mo ago
you can only have one entrypoint per project. and entrypoint is... $mains
MODiX
MODiX15mo 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
Pobiega15mo ago
one of these.
sunny innit
sunny innit15mo ago
ohhhhh i see public static void Main(string[] args) { } isnt this the same that im already using?
Pobiega
Pobiega15mo 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 innit15mo ago
oooooooooooooooooh now i see it
sunny innit
sunny innit15mo ago
Pobiega
Pobiega15mo ago
that method is not related to your problem
sunny innit
sunny innit15mo ago
i see o_o
Pobiega
Pobiega15mo 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 innit15mo 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
Pobiega15mo ago
show me your Program.cs
sunny innit
sunny innit15mo 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 innit15mo ago
BlazeBin - arbidrczmcub
A tool for sharing your source code with the world!
sunny innit
sunny innit15mo ago
i think thats it
Pobiega
Pobiega15mo ago
do you have any other .cs files in your project?
sunny innit
sunny innit15mo ago
Like different saved files? of this particular project?
Pobiega
Pobiega15mo ago
I mean exactly what I wrote
sunny innit
sunny innit15mo 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
Pobiega15mo 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 innit15mo ago
oh i see
Pobiega
Pobiega15mo ago
so all .cs files will be part of the compilation
Pobiega
Pobiega15mo ago
example:
sunny innit
sunny innit15mo ago
ohhhh i see; How do i locate that?
Pobiega
Pobiega15mo 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 innit15mo ago
I use Visual Studios as instructed
Pobiega
Pobiega15mo ago
... do you really? VS, or VS Code?
sunny innit
sunny innit15mo ago
i believe its the latest version
sunny innit
sunny innit15mo ago
Pobiega
Pobiega15mo 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 innit15mo ago
sunny innit
sunny innit15mo ago
This is pretty interesting theres so many things to consider within this
Pobiega
Pobiega15mo ago
this is .NET Framework? why?
sunny innit
sunny innit15mo ago
Yeah! I havent been instructed to use anything else. from the first assignment to this
Pobiega
Pobiega15mo ago
were you actively instructed to use .NET Framework?
sunny innit
sunny innit15mo ago
Yeah from the very first assignment
Pobiega
Pobiega15mo ago
okay.
sunny innit
sunny innit15mo ago
the literature states nothing else too
Pobiega
Pobiega15mo ago
thats from 2017, and is essentially dead just so you are aware
sunny innit
sunny innit15mo ago
ohhh i see just for my own curiosity; what is the replacement that people use now?
Pobiega
Pobiega15mo ago
.NET
sunny innit
sunny innit15mo ago
Also if i use that would it break my program?
Pobiega
Pobiega15mo ago
specifically .NET 7 is the latest version
sunny innit
sunny innit15mo ago
I see 😮
Pobiega
Pobiega15mo 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 innit15mo 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
Pobiega15mo ago
I dont want to see the reference or expanded code view
sunny innit
sunny innit15mo ago
okay
sunny innit
sunny innit15mo ago
sunny innit
sunny innit15mo ago
just like this?
Pobiega
Pobiega15mo ago
okay, so show me ProgramHelper.cs yes
sunny innit
sunny innit15mo ago
sunny innit
sunny innit15mo ago
theres just one reference there
Pobiega
Pobiega15mo 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 innit15mo 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
Pobiega15mo ago
they are always called Main but you see two of them right? One in Program, one in ProgramHelper
sunny innit
sunny innit15mo ago
Yeah? they're identical
Pobiega
Pobiega15mo ago
And how many were allowed per project? You currently have 2.
sunny innit
sunny innit15mo ago
Only one is allowed oh
Pobiega
Pobiega15mo ago
Correct.
sunny innit
sunny innit15mo ago
So which one am i allowed to delete? And also noob question
Pobiega
Pobiega15mo ago
looks to me like your entire program is contained within Program.cs
sunny innit
sunny innit15mo ago
There's two instances hidden there; But i only see one in the actual code
Pobiega
Pobiega15mo ago
but I have not seen the code for ProgramHelper ?
sunny innit
sunny innit15mo ago
So within the code itself as i linked above
Pobiega
Pobiega15mo ago
yes
sunny innit
sunny innit15mo ago
there's only one main method; Why is it hidden in these sidebars? Does this only apply to Main methods?
Pobiega
Pobiega15mo ago
?? sidebars? what are you talking about
sunny innit
sunny innit15mo ago
hahahaha okay
sunny innit
sunny innit15mo ago
sunny innit
sunny innit15mo 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
Pobiega15mo ago
instances?
sunny innit
sunny innit15mo ago
Like two different Main methods
Pobiega
Pobiega15mo ago
You do realize that ProgramHelperis a different file right? its literally two different .cs files
sunny innit
sunny innit15mo ago
i did not take that into account o_o
Pobiega
Pobiega15mo ago
sunny innit
sunny innit15mo ago
Sorry for all the stupid questions lol
Pobiega
Pobiega15mo 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 innit15mo ago
If i'd like to delete ProgramHelpers completely; How would one go about that? like within this project
Pobiega
Pobiega15mo ago
click it, press delete, confirm
sunny innit
sunny innit15mo 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
Pobiega15mo ago
flawlessly is a strong word :p
sunny innit
sunny innit15mo ago
Thank you so much yet again; You should become a Teacher if you you're not already hahaha Oh?!?!
Pobiega
Pobiega15mo ago
Eh, I prefer the pay being a software developer gives...
sunny innit
sunny innit15mo ago
I do not blame you hahaha
sunny innit
sunny innit15mo ago
sunny innit
sunny innit15mo ago
woopwoop
Pobiega
Pobiega15mo 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 innit15mo 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
Pobiega15mo 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 innit15mo ago
Thats wildddddd
Pobiega
Pobiega15mo 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 innit15mo ago
Nono, they have SATs, Exams where the results will factor in if they take you in
Pobiega
Pobiega15mo ago
okay
sunny innit
sunny innit15mo 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
Pobiega15mo ago
you mean best case kekw can't resist making stockholm jokes.
sunny innit
sunny innit15mo ago
Hahahah i mean you're not wrong XD
Accord
Accord15mo 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
More Posts
GIT Question for companySorry if this is a really noob question, but I don't want to bother my manager and also I've never w✅ Debugging razor component page isn`t workingCould you please tell me why the debugger on the .razor page may not work? On the page to which visu❔ How to read configuration based on environmentI have a stored my connection string as configuration in web.config. Now I have stored the same conn❔ PlayStation 2 startup recreationWondering how I can recreate the iconic PS2 startup, and whag framework would fit this question❔ Send using http post with multiple parameters, to an endpoint defined in C# with minimal APIsI've got an endpoint like so: ```csharp app.MapPost("/endpoint1", async ValueTask<IResult?> (string ❔ Does AssemblyLoadContext use dependencies that are already loaded in the default context?I'm not debugging any issues, I'm just trying to make sure I understand what I can expect this subsy✅ Can't use `gh webhooks forward`: "Error: you must be authenticated to run this command"I'm trying to forward github webhooks to a local server for testing purposes, following <https://doc❔ need some help for school assignment - changing image via variablehey, having problems building a microsoft form in c#, part of my assignment is to build a basic educ❔ Writing to StreamWriter FailsHi, I was experimenting with permanently saving things for the first time and ran into problems. Des❔ road mapi have a question, basic c# and .which topic should I study after netcore 5 training?