why doesnt my console application let me make Main() class?
it says "Program does not contain a static "Main" method suitable for an entry point"
36 Replies
show your code
are you using NET 6 + top level statement ?
yes
i think
its literally only this:
also why cant i put program.<name>(); in main
You can either:
1. Not use a
Main()
method and use top-level statements
2. Use a class and the Main()
method
No inbetween
Either no boilerplate or full boilerplatei would rather not use main then but how do I determine a starting object for my app then?
Main needs to be static, inside a static class
no
Program is not static
ok but how do i make some event so I can run void webhooks()
i need something
Program.cs
does not work cause my void webhooks is inside a namespace
and i cant put that outside
how?
just put it outside
then it does not work
$nodetail
wait wait i will send you a screenshot
so move it out of the namespace
you don't need a Program class
it doesnt want to send
the image
yeah you've sent it twice actually
but i moved it out
oh you mean void webhooks()
to move it?
everything
no, everything
oh
alr
everything you have in Program
this.handlers = default(DiscordRpc.EventHandlers);
DiscordRpc.Initialize("BOT ID", ref this.handlers, true, null);
this.handlers = default(DiscordRpc.EventHandlers);
DiscordRpc.Initialize("BOT ID", ref this.handlers, true, null);
this.presence.details = "Text 1";
this.presence.state = "Text 2";
this.presence.largeImageKey = "image";
this.presence.smallImageKey = "image";
i wont be able to use this.
outside a namespace
thats a big problem
are you sure you are using top-level statement?
no
how do i check
so i dont need this.?
no
what was this. even for?
this.
refers to the current containing type
in your case Program
a namespace cannot directly contain members such as fields, methods or statements
what do i do now
what i sent
oh
what does = default; do i wanna know
didn't you already use it yourself
no
i think no
only in rpc code which i copied
also why does it say one error and it says program does not contain a static "Main" method suitable for an entry point. how do i fix that error cause nothing is read in my code
it says line 1 but there is nothing in line 1
fixed, i compiled it and it fixed itself