C
C#3y 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.LVT3y ago
show your code are you using NET 6 + top level statement ?
Nikolaaa
NikolaaaOP3y 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
Angius3y 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
NikolaaaOP3y ago
i would rather not use main then but how do I determine a starting object for my app then?
Tvde1
Tvde13y ago
Main needs to be static, inside a static class
ero
ero3y ago
no Program is not static
Nikolaaa
NikolaaaOP3y ago
ok but how do i make some event so I can run void webhooks() i need something
ero
ero3y ago
Program.cs
WebHooks();

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

void WebHooks()
{
// code
}
Nikolaaa
NikolaaaOP3y ago
does not work cause my void webhooks is inside a namespace and i cant put that outside
ero
ero3y ago
how? just put it outside
Nikolaaa
NikolaaaOP3y ago
then it does not work
ero
ero3y ago
$nodetail
Nikolaaa
NikolaaaOP3y ago
wait wait i will send you a screenshot
Nikolaaa
NikolaaaOP3y ago
ero
ero3y ago
so move it out of the namespace you don't need a Program class
Nikolaaa
NikolaaaOP3y ago
Nikolaaa
NikolaaaOP3y ago
it doesnt want to send the image
ero
ero3y ago
yeah you've sent it twice actually
Nikolaaa
NikolaaaOP3y ago
but i moved it out oh you mean void webhooks() to move it?
ero
ero3y ago
everything no, everything
Nikolaaa
NikolaaaOP3y ago
oh alr
ero
ero3y ago
everything you have in Program
Nikolaaa
NikolaaaOP3y 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.LVT3y ago
are you sure you are using top-level statement?
Nikolaaa
NikolaaaOP3y ago
no how do i check
ero
ero3y 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
NikolaaaOP3y ago
so i dont need this.?
ero
ero3y ago
no
Nikolaaa
NikolaaaOP3y ago
what was this. even for?
ero
ero3y ago
this. refers to the current containing type in your case Program
Nikolaaa
NikolaaaOP3y 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
ero3y ago
what i sent
Nikolaaa
NikolaaaOP3y ago
oh what does = default; do i wanna know
ero
ero3y ago
didn't you already use it yourself
Nikolaaa
NikolaaaOP3y 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
Want results from more Discord servers?
Add your server