code builds but hangs while running

code: https://paste.pythondiscord.com/KTVQ when i build it in release, everything works fine. but when i run in release, it just hangs and does nothing, even though all i'm doing is this:
class Program
{
// ... <- nothing up here is run

static void DisplayHelp()
{
string help = """
This is a test help screen.

What do you think?
""".Trim();

Console.WriteLine(help);
}

static void Main()
{
DisplayHelp();
}
}
class Program
{
// ... <- nothing up here is run

static void DisplayHelp()
{
string help = """
This is a test help screen.

What do you think?
""".Trim();

Console.WriteLine(help);
}

static void Main()
{
DisplayHelp();
}
}
97 Replies
Angius
Angius4mo ago
Well, your Main() only calls DisplayHelp() So... that's what runs You never call Execute(), for example
Evyr
Evyr4mo ago
What do you mean by hang? When I run the paste you sent it prints out the estring in DisplayHelp then exits
slowly losing it
slowly losing itOP4mo ago
it just doesn't output:
No description
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
add logs.. how?
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
there is zero output did you read literally anything in the post
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
yes, of course
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
Execute() isn't called because it's for later yes of course i read that
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
No description
Evyr
Evyr4mo ago
yeah there's nothing wrong with the code
No description
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
still no output
Evyr
Evyr4mo ago
press enter
slowly losing it
slowly losing itOP4mo ago
wtf is conhost
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
yeah i mentioned that in the post build works fine execution fails
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Evyr
Evyr4mo ago
navigate to the bin/release folder and run the executable created by building it'll work fine
slowly losing it
slowly losing itOP4mo ago
even stripping the entire file (singular C# file by the way) and writing this doesnt work:
Console.WriteLine("Hello world");
Console.WriteLine("Hello world");
yes i tried that too nope
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
pressing escape does nothing
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Angius
Angius4mo ago
Try running it from Powershell or VS Code's built-in terminal
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
i'm using vscode's terminal i'll try powershell is conhost just cmd?
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
it hangs in PS too
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
:hmmHD:
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
ah i see
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
i'm not using the window then
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
No description
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
integrated terminal it hangs there too
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
all i did was change .Main() to print hello world instead Ctrl+C doesn't work to stop the terminal surprisingly
Evyr
Evyr4mo ago
click on the output tab
MODiX
MODiX4mo ago
TeBeCo
add -v:diag
Quoted by
React with ❌ to remove this embed.
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
an absolute fuck ton of text is speeding through my terminal
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
No description
Evyr
Evyr4mo ago
scratch that, debug console, not output
slowly losing it
slowly losing itOP4mo ago
debug console is empty
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Evyr
Evyr4mo ago
huh, odd
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
nope it stopped like i said building works fine
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
No description
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Angius
Angius4mo ago
And are there any others?
slowly losing it
slowly losing itOP4mo ago
No description
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
it's in a single file
it doesn't need to be Program.cs - it just needs a .Main() entry point
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX4mo ago
If your code is too long, you can post to https://paste.mod.gg/, save, and copy the link into chat for others to see your shared code!
slowly losing it
slowly losing itOP4mo ago
the chess bot i'm making on the side has an entry point in it's UCI.cs file - there it has top-level statements, which are essentially the same as a .Main() entry point no which is why i'm confused as to why it's acting like this i swear to god if it's my anti-virus i'm uninstalling thsi thing
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
it is, yes
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
HOLY FUCK IT WAS MY ANTIVIRUS i fucking hate this thing
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
No description
Angius
Angius4mo ago
Make some D:/MyProjects and use that
slowly losing it
slowly losing itOP4mo ago
you can do that?
Angius
Angius4mo ago
Uh, yeah?
slowly losing it
slowly losing itOP4mo ago
how do you make a D drive?
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Angius
Angius4mo ago
Or partition an existing one But yeah, C:/MyProjects or whatever will do as well I forgot not everybody has more than one drive lol
Evyr
Evyr4mo ago
either install another storage device, or if you free up some space, shrink your C drive volume and make a new volume using the disk management tool
slowly losing it
slowly losing itOP4mo ago
windows defender is better than other antiviruses i swear and it's free
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
a computer does what it's told to :shrug:
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Angius
Angius4mo ago
To be fair, the fact that OneDrive can cause such issues is... counterintuitive lol
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
yeah fair enough my antivirus is nearly done uninstalling on the bright side
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
:thumbsup:
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
slowly losing it
slowly losing itOP4mo ago
alright, will do
Evyr
Evyr4mo ago
I'm curious why you're using these in conjunction with the ThrowException method that just prints out the parameters and calls Environment.Exit(0); instead of throwing IndexOutOfRangeException and OverflowException with the message as one string passed into their constructors
No description
slowly losing it
slowly losing itOP4mo ago
i'd prefer not to use a stack trace, since it looks kinda ugly tbh
Evyr
Evyr4mo ago
fair ig
slowly losing it
slowly losing itOP4mo ago
i'd prefer to have just
OverflowError: cannot increment block value above 255.
OverflowError: cannot increment block value above 255.
than
System.Exception: OverflowError: cannot increment block value above 255.
at ...
at ...
at ...
at ...
System.Exception: OverflowError: cannot increment block value above 255.
at ...
at ...
at ...
at ...
Evyr
Evyr4mo ago
though you shouldn't be using 0 as the argument for Environment.Exit in this case, since it isn't completing successfully
No description
slowly losing it
slowly losing itOP4mo ago
what happens when you exit with 1?
Evyr
Evyr4mo ago
🤷‍♂️ mess around with it and see
slowly losing it
slowly losing itOP4mo ago
seems like the exit code doesn't matter

Did you find this page helpful?