Share via


Console window doesn't show anything

Question

Wednesday, November 25, 2015 6:03 PM

Hello, 

I have a promblem which I haven't found any solutions in the internet for it:

I have a code in visual studio when developing a console application - even the simplest code, like: Console.WriteLine("Hello!"); .

When I try to run the progran without debugging (pressing Ctrl+F5), the console window opens, but doesn't show anything except the cursor. Even the "press any key to continue" line doesn't appear. Another thing I have noticed, is that if I try to type something in the console widnow, it doesn't show it.

But, If I make a breakpoint after this line in code, and run the program with debugging (F5 only), I can see the word "Hello!" in the console window.

By the way, I have the visual studio 2010, 2013 and 2015 in my computer, and all have the same problem...

I really need to find the solution for this problem, so I thank everyone who tries to help me.

Thanks again!

All replies (10)

Friday, November 27, 2015 1:27 AM ✅Answered

Hi tomere,

Please try add breakpoint on the line of Console.WriteLine() and hit F5 to debug it. When hit the breakpoint, please right-click on the Console.WriteLine() to "Add Watch" and then hit F10 to run to next line. Now please check the watch result in Watch window to check whether there any exception occurred.

If no exception occurred, please try with following steps to troubleshoot this problem.

  1. Run Visual Studio as Administrator.
  2. Run Visual Studio in safe mode with "Deven.exe /SafeMode" command to prevents all third-party VSPackages from loading when Visual Studio starts, thus ensuring stable execution.
  3. Close all third part software, such as antivirus software.
  4. Please check the ActiveLog.xml under the path of %AppData%\Microsoft\VisualStudio\14.0. This file will log all operations when you operate Visual Studio.

Best Regards,
Weiwei


Monday, November 30, 2015 2:53 AM ✅Answered

Hi tomere,

>>in the Add Watch window it showed me the message "The name 'WriteLine' does not exits in the current context".

When you see this message, because the line of code which breakpoint hit has not been run. When it hit the breakpoint on the line of code, please enter F10 to run to next line of code, and then Add Watch to the line which you add breakpoint.

>>Do I need to run VS as Administrator and in Safe Mode together, or to do only the second if the first doesn't work?

Please do these steps independently. If the first one doesn't work, then do the second step.

>>I didn't understand- where do I need to put the command  "Deven.exe /SafeMode". In the command prompt? In the software itself, as a line of code?

Please open the Developer Command Prompt for VS2015 window as administrator which under the Visual Studio 2015 folder in Start -> All Program first. Then locate to the path of Devenv.exe, which often under the folder of Microsoft Visual Studio 14.0\Common7\IDE. The command as below shows.

**Now you can input the command of "devenv.exe /SafeMode" to run Visual Studio in safe mode.

>>When I get into the path of %AppData%\Microsoft\VisualStudio\14.0. , I dont find any ActiveLog.xml file. The closest name I can find is: ActivityLog.xml.

Before you operate your Visual Studio, please open the switch of Log with command of "devenv /log" (also use the Developer Command Prompt for VS2015 window). Then please do your operation with Visual Studio.

In addition, since this problem is occurred with VS2010, VS2013 and VS2015, I think there may be something wrong on the Console window. I suggest you change another computer to make sure whether this problem is related to your current computer. If yes, I'm afraid that you need to restore your computer environment.

Best Regards,
Weiwei


Monday, November 30, 2015 9:51 PM ✅Answered

Hi again,

I tried to turn off the antivirus, and the problem dissapeard. I discovered that when disabeling the option to scan programms when they run, the program behaves as usual.

Thank you all very much for helping me to solve my problem. I really appreciate that!

Thank you again and have a noce day!

tomere


Wednesday, November 25, 2015 7:26 PM

If you try Write instead of WriteLine, does the cursor stay after the presumptive position of “Hello!” or “Press any key”? Maybe the console has inappropriate colours.


Wednesday, November 25, 2015 7:42 PM

Hi tomere,

Are you saying that your console window get close immediately after pressing F5? If so then you have to put Console.ReadLine(); after your WriteLine() code. See below example.

using System;

namespace BasicHelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Console.ReadLine();
        }
    }
}

Thanks,

Sabah Shariq


Thursday, November 26, 2015 7:21 PM

No, the cursor stays at the upper-left corner of the window.

Thank you anyway!


Thursday, November 26, 2015 7:23 PM

I pressed Ctrl+F5, so then the program starts without debugging, so at the end of the program, it waits for me to press any key and then it closes.

Thanks anyway!


Friday, November 27, 2015 3:37 PM

Hi Weiwei, 

I tried your first suggestion, and in the Add Watch window it showed me the message "The name 'WriteLine' does not exits in the current context". This message hasn't changed also after pressing F10 and pressing on the little refresh icon next to this message. I also noticed that if I right click on different parts of the code line (like: Console, WriteLine and Hello) and then choose the Add Watch option, it refers to the word that was chosen, but the message isn't different by its meaning at each time.

I don't know if it these messeges are good or not, so I don't know if I have to continue to the other steps in your solution.

Also, I don't know how to do all of the steps that you mentioned, like:

1. Do I need to run VS as Administrator and in Safe Mode together, or to do only the second if the first doesn't work?
2. I didn't understand- where do I need to put the command  "Deven.exe /SafeMode". In the command prompt? In the software itself, as a line of code?

3. When I get into the path of %AppData%\Microsoft\VisualStudio\14.0. , I dont find any ActiveLog.xml file. The closest name I can find is: ActivityLog.xml.

I would be very happy If you could explain me these things, and if the message I got at the beginning is OK, and I'm sorry about my limited knowledge at this topic...

Thank you very much!


Monday, November 30, 2015 9:43 PM

Hi Weiwei, 

First I did the "Add Watch" action and also before and also after the program passed this line of code, I had the same message that the word WriteLine doesn't exist in the current context. But, then I tried the next level and wrote the code lines that were given in the command prompt, and although I could't find the ActiveLog.xml file in the path you mentioned, I created a program and pressed ctrl+F5 and the word "hello" and the message after that appeared, as it should be.

After closing all these programs, the program behaved correctly, but after some minutes the problem went back. Maybe there is a way to maintain the state of the program when it is in the safe mode, also in the regular mode? Maybe it is related to the antivirus that return working as usual?

I want to thank you very much for helping me with your patient about things I haven't known before.

Best Regards,

tomere


Tuesday, December 1, 2015 1:32 AM

Hi tomere79,

I'm glad that you have resolved your problem. Please mark the helpful reply as answer, which is benefit to other communities who has the same problem.

If any question about Visual Studio in future, please feel free to come back to our forum.

Best Regards,
Weiwei