Visual Studio 2015: Output from build Window is empty - c#

I'm a super-beginner coder and trying to follow a training video on C# in Visual Studio 2015. The tutorial has me do a new Visual C# project as a Console Application. When I run my code using Ctrl+F5, it launches my code in the console as expected, but the Output --> Show output from build window is completely empty.
I've scoured this site and others for a solution. These are my current VS2015 settings, I've tried changing these with no success:
Show Output window when build starts is CHECKED
Redirect all Output Window text to the Immediate Window is UNchecked.
This is the code, verbatim what is shown in the tutorial:
using System;
namespace Hello
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World");
}
}
}
When the same code is run in the tutorial, the resulting output appears immediately in the Output window:
1>------ Build started: Project: Hello, Configuration: Debug Any CPU ------
1> Hello -> c:\users\[name]\documents\visual studio 2015\Projects\Hello\Hello\bin\Debug\Hello.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
I can see my Output window and I expect to receive this, but I get nothing. First time using Visual Studio, what am I missing?

Prior to adding Console.Read(); at the end of my code, running the code would launch the console with the following output:
Hello, World
Press any key to continue...
But, the build output window in VS remained blank as originally described.
After adding Console.Read();, the output in console no longer contained
Press any key to continue...
However, the build output in VS now displays what is expected as described in Original Post.
If I then remove Console.Read();, reverting back to my original code, the console output is back to original, and the VS build output window still gives expected output...
I suspect that, using Visual Studio for the first time, it had never been directed to write to the Output window, which was accomplished here with Console.Read(); and should do this going forward...
Link to solution I used:
https://stackoverflow.com/a/5301276/11953574

Related

Can't type anything on Visual Studio Code's C# output

so i was trying to run a really basic C# program on vscode, here's the code:
using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
string Name;
Console.Write("Input your username:\n");
Console.Write("u/");
Name = Console.ReadLine();
Console.Write("\nSo your username is u/" + Name);
}
}
}
And naturally, it outputs:
Input your username:
u/
Except that i can't type anything next to the "u/", not even below.
it doesn't even freeze, popup an error or something like that, it just shows nothing.
and the same problem happens with C and C++. any tip?
Solutions
This problem is solved in two steps:
Adding Developer Command Prompt to Visual Studio Code
Updating "console" field in the launch.json file.
1. Adding Developer Command Prompt to Visual Studio Code
If you create C# programs with the terminal or powershell that comes with Visual Studio Code, you will be using the old toolkit. In this case, launch.json and tasks.json files aren't created in the .vscode directory when you compile the project, and you cannot use the new features of the C# programming language through the old toolset (only C# 5.0 is supported). To add a new terminal to Visual Studio Code, use the Control Shift P shortcut and enter the command "Terminal: Select Default Profile". Click on the settings icon of any default terminal on the window that opens and name the new terminal profile "Developer Command Prompt".
To check that the operation was successful, use the Control Shift P shortcut to view the new terminal listed and enter the command "Terminal: Select Default Profile".
Use the Control Shift P shortcut and enter the "Preferences: Open Setting (JSON)" command to open the setting.json file. You can view the newly added terminal information named "Developer Command Prompt" under "terminal.integrated.profiles.windows" settings. Update this field below:
"Developer Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [
"/K",
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\Tools\\VsDevCmd.bat",
],
"icon": "terminal-cmd"
}
Open "Developer Command Prompt" and create new project:
> mkdir TestProject
> cd TestProject
> dotnet new console
To receive data input from the console while debugging, change the configuration in the launch.json file as follows:
"console": "integratedTerminal"
When you press the F5 button to debug the opened project, a panel will open to select the environment. Select ".NET 5+ and .NET Core" from this field. In this step, the .vscode directory (launch.json and task.json files) will be created.
Accept all suggestions by following the prompts at the bottom right of Visual Studio Code as the new toolset will be used for the first time on the system. At this stage, launch.json and task.json files will be created under the .vscode directory.
2. Updating "console" Field In The launch.json
To receive data input from the console while debugging, change the configuration in the launch.json file as follows:
"console": "integratedTerminal"
3. Debugging On Test Project
Press F5 to debug the project:
References
Visual Studio Code - Terminal Profiles
OmniSharp - Instructions For Setting Up The .NET Core Debugger
Set As Default The Developer Command Prompt Of VS In VS Code
Debug Console Window Cannot Accept Console.ReadLine() Input During Debugging

How to single step instructions when debugging C#?

i have a C# project that i'm working on and i'm trying to debug an issue that cause an unhandled exception. The problem is that whenever i place a breakpoint and it gets hit if i press "Step Into" it simply resumes execution instead of stepping to the next instruction. Does anyone know how to step C# instructions 1 by 1 instead of resuming execution?
I'm using Visual Studio 2019 on Windows 10 to do the debugging. The project is a solution with multiple projects where the main project is written in C# with others written in C++ and C. I am able to load the symbols successfully for the C# project.
Here is the github repository.
Edit:
The project i'm working on is an NES emulator called Mesen and the issue i'm trying to debug is an unhandled exception during online play. The exception triggers apparently randomly and i've tried multiple actions to try and trigger it but it still only happened on its own.
private void StartEmuThread()
{
if(_emuThread == null) {
_emuThread = new Thread(() => {
try {
InteropEmu.Run();
_emuThread = null;
} catch(Exception ex) {
MesenMsgBox.Show("UnexpectedError", MessageBoxButtons.OK, MessageBoxIcon.Error, ex.ToString());
_emuThread = null;
}
});
_emuThread.Start();
}
UpdateMenus();
}
I'm trying to put a breakpoint on InteropEmu.Run() and single step from there but every time i hit step into it just resumes the program.
Here is a screenshot from visual studio during when i hit the breakpoint on InteropEmu.Run()
And here it resumes after i press step into at the top in the debugging toolbar.
Here is the exception that i'm trying to troubleshoot
Thanks
I've tried out some different build options and it turns out single stepping is disabled for Release builds but not for Debug builds. I tried a debug build and this time it worked.

How to overcome Debug adapter process has terminated unexpectedly with C# extension

I run into the problem where VSCode prompts
Debug adapter process has terminated unexpectedly
For a C# project created using console template; when I debug it by pressing "F5" key.
I do not have any problems in compiling the project.
I have performed dotnet run on the project folder. I see the "Hello World" printed on the command prompt without any problem.
My version strings
VSCode : 1.14.2
dotnet : 2.0.0-preview2-25407-01
C# extn : 1.11.0
OS : Microsoft Windows NT 6.1.7601 Service Pack 1 (Windows 7 - 64 bit)
I do not have any info in event log.
How do I tackle this error?
[Update]
OmniSharp debug server is exiting/closing when they are launched suspiciously!
Where do I collect the log for the OmniSharp debug server?
I do not have anything printed on my Output window in VS Code. I do not even see OmniSharp log source in the Output filter dropdown.
[Additional information]
Noted same error when I run the application in non-debug mode as well using "Ctrl+F5" key.
Browsed VS Code's source code in github; the error message appears when debug server is not in disconnected state while exiting the server. Pursuing further on building a call graph, onServerExit are called
1. close event of the socket create in [connectServer] (https://github.com/Microsoft/vscode/blob/fbece01268f4e5d290a470b328eea6312069eda0/src/vs/workbench/parts/debug/electron-browser/rawDebugSession.ts#L433)
2. exit event of the debug server process launched in [startServer] (https://github.com/Microsoft/vscode/blob/fbece01268f4e5d290a470b328eea6312069eda0/src/vs/workbench/parts/debug/electron-browser/rawDebugSession.ts#L437)
Now my question gets refined to why is the debug server exiting / closing when they get created?
Could this be due to permissions or port numbers or something else? Where should I look for such problems in my machine?

Visual Studio Code output window stays empty using scriptcsRunner

I've been trying to fiddle around with Scriptcs and since I don't always want to fire up Visual Studio and use the interactive window, I'd tried my hand with Visual Studio code.
These are the steps I've taken:
#powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/scriptcs-contrib/svm/master/install/installer.ps1'))" && SET PATH=%HOME%\.svm\bin\;%HOME%\.svm\shims\;%PATH%
svm install 0.15.0
VS Code -> ext install scriptcsRunner -> Restart VS Code
Using a command prompt and issuing scriptcs [enter] Console.WriteLine("foo"); [enter] returns foo.
Using sublime Text 3, I get the same results. However, in Visual Studio code executing it with Ctrl + Shift + R gives me an empty Output window. How can I debug and rectify this?

Microsoft.Lightswitch.Build.Tasks.Targets(168,5): application definition contains critical errors

I have a complex lightswitch application that was created using visual studio 2013, and then I upgrade it to using visual studio 2015. the solution was working fine, I even did a couple of deployment for it. Now I am trying to build it from a new machine and the build hangs (it never finishes). The output console is displaying an error: Microsoft.Lightswitch.Build.Tasks.Targets(168,5): application definition contains critical errors
I tried Google for a solution but could not find one that works in my case, I already checked the Link1 and this one Link2
When I cancel the build another similar error is displayed this is the output console:
------ Build started: Project: Agency Tool.Server, Configuration: Debug Any CPU ------
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\LightSwitch\v5.0\Microsoft.LightSwitch.Build.Tasks.targets(168,5): error : Application definition contains critical errors.
------ Build started: Project: Agency Tool.DesktopClient, Configuration: Debug Any CPU ------
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\LightSwitch\v5.0\Microsoft.LightSwitch.Build.Tasks.targets(217,5): error : Application definition contains critical errors.
------ Build started: Project: Agency Tool, Configuration: Debug Any CPU ------
The data necessary to complete this operation is not yet available. (Exception from HRESULT: 0x8000000A)
========== Build: 0 succeeded, 3 failed, 0 up-to-date, 0 skipped ==========
Resolved:
We noticed that in the main project properties--> extensions tab, Microsoft Lightswitch Extensions was not selected (I don't know what caused it to be unchecked, but I did not do it manually). However when we checked it the error disappeared.

Categories

Resources