C
C#2y ago
Nikolaaa

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
FroH.LVT
FroH.LVT2y ago
show your code are you using NET 6 + top level statement ?
Nikolaaa
Nikolaaa2y ago
yes i think its literally only this:



void Main()
{
program.webhooks();
}



void Main()
{
program.webhooks();
}
also why cant i put program.<name>(); in main
Angius
Angius2y ago
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 boilerplate
Nikolaaa
Nikolaaa2y ago
i would rather not use main then but how do I determine a starting object for my app then?
Tvde1
Tvde12y ago
Main needs to be static, inside a static class
ero
ero2y ago
no Program is not static
Nikolaaa
Nikolaaa2y ago
ok but how do i make some event so I can run void webhooks() i need something
ero
ero2y ago
Program.cs
WebHooks();

void WebHooks()
{
// code
}
WebHooks();

void WebHooks()
{
// code
}
Nikolaaa
Nikolaaa2y ago
does not work cause my void webhooks is inside a namespace and i cant put that outside
ero
ero2y ago
how? just put it outside
Nikolaaa
Nikolaaa2y ago
then it does not work
ero
ero2y ago
$nodetail
Nikolaaa
Nikolaaa2y ago
wait wait i will send you a screenshot
Nikolaaa
Nikolaaa2y ago
ero
ero2y ago
so move it out of the namespace you don't need a Program class
Nikolaaa
Nikolaaa2y ago
Nikolaaa
Nikolaaa2y ago
it doesnt want to send the image
ero
ero2y ago
yeah you've sent it twice actually
Nikolaaa
Nikolaaa2y ago
but i moved it out oh you mean void webhooks() to move it?
ero
ero2y ago
everything no, everything
Nikolaaa
Nikolaaa2y ago
oh alr
ero
ero2y ago
everything you have in Program
Nikolaaa
Nikolaaa2y ago
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
FroH.LVT
FroH.LVT2y ago
are you sure you are using top-level statement?
Nikolaaa
Nikolaaa2y ago
no how do i check
ero
ero2y ago
DiscordRpc.EventHandlers handlers = default;
DiscordRpc.Initialize("BOT ID", ref handlers, true, null);

DiscordRpc.RichPresence presence = default;
presence.details = "Text 1";
presence.state = "Text 2";
presence.largeImageKey = "image";
presence.smallImageKey = "image";
DiscordRpc.EventHandlers handlers = default;
DiscordRpc.Initialize("BOT ID", ref handlers, true, null);

DiscordRpc.RichPresence presence = default;
presence.details = "Text 1";
presence.state = "Text 2";
presence.largeImageKey = "image";
presence.smallImageKey = "image";
Nikolaaa
Nikolaaa2y ago
so i dont need this.?
ero
ero2y ago
no
Nikolaaa
Nikolaaa2y ago
what was this. even for?
ero
ero2y ago
this. refers to the current containing type in your case Program
Nikolaaa
Nikolaaa2y ago
private DiscordRpc.EventHandlers handlers;
private DiscordRpc.RichPresence presence;
private DiscordRpc.EventHandlers handlers;
private DiscordRpc.RichPresence presence;
a namespace cannot directly contain members such as fields, methods or statements what do i do now
ero
ero2y ago
what i sent
Nikolaaa
Nikolaaa2y ago
oh what does = default; do i wanna know
ero
ero2y ago
didn't you already use it yourself
Nikolaaa
Nikolaaa2y ago
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