Project's exe from the bin folder acting different from the one in the VS Debug

StackOverflow https://stackoverflow.com/questions/23666746

  •  22-07-2023
  •  | 
  •  

سؤال

I'm very VERY new at C# and I have a question. I want to make a riddle for my friends. Anyway, I made a Console APP that when open asks you if you want to play a game, if you type Yes you get a "Good, now chenk your desktop. You've got a gift." message ... if they answer No then the app closes. Atleast that's what I get in the debug mode in VS (Pressing F5 or Ctrl + F5) Anyway when I go to the project's folder and open the .exe from there something else happens. The first "page" shows and asks me if I want to play a game. Now whatever I do when I press enter the exe will close. Why? I mean in the debug in VS it's working just fine. Why would that exe act differently and how can I fix it?

Edit: I guess there's something wrong with the code because when I start it with debugging it gives the same problem but when I start it without debug (Ctrl + F5) it works fine.

هل كانت مفيدة؟

المحلول

It is possible you haven't built the latest build. You can do so by heading to the Build Output option and changing it from Debug to Release.

Change Output

Afterwards, head to the build menu and select "Build Solution". You should now have the latest build in you bin/release folder (you can verify by checking the Modified date).

Build Solution

Update:

After taking at look at your code you were missing one vital line, "Console.ReadLine();". Without it, you application will execute your Console.WriteLine(); and immediatly exit. "Console.ReadLine();" will allow your program to allow the user to press enter before exiting. Here is the updated code.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top