7
votes

Today is my first day learning C#. I am experienced with Java and C and usually don't run into problems I cant solve. I have always dreaded using Visual Studio due to the never ending errors I would receive when I use to run my assembly programs. Today I wanted to just run a simple hello world program. After running the program, I am getting the following errors.

'dotnet.exe' (CoreCLR: DefaultDomain): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.7\System.Private.CoreLib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Users\cansh_000\source\repos\Program\Program\bin\Debug\netcoreapp2.0\Program.dll'. Symbols loaded.
'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.7\System.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.7\System.Console.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.7\System.Threading.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.7\System.Runtime.Extensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The program '[2852] dotnet.exe' has exited with code 0 (0x0).`

Code down Below

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

Any help would be appreciated

3
None of that output is an error message. It says your program ran to completion successfully and then exited.Dai
Maybe you should show us the code.LarsTech
Could we have a look at your program? My guess is that this is a console application and you didn't end your code with Console.Read() which is required so that you can see the output of your program without it exiting.41686d6564
Is it a Console Application project that doesn't have any pause after executing?St. Pat
I would suggest your code is running just fine. You must remember that VS doesn't keep consoles open after they're finished it closes them immediately.tinstaafl

3 Answers

13
votes

None of that output is an error message. It says your program ran to completion successfully and then exited. The C# compiler does not add a "Press any key to continue..." message after the program completes unlike some C compilers - so after the program runs it disappears leaving no-trace on screen.

Look for your void Main, int Main, (or async Task Main) method and add Console.WriteLine("done!"); Console.ReadLine(); immediately before the closing curly brace }.

Update for Visual Studio 2019:

Since C# 8.0 in VS2019, the IDE now does run console-mode applications using a special host process that will add the "Press any key to continue..." message after the program has finished running.

4
votes

These aren't errors, they are just messages, showing that module XY was loaded. They can be very distracting from the debug messages you actually want to see.

If they disturb you (like me!) and you just want to turn off those messages in Visual Studio, there are two ways to do that:


1st Way to disable it

Go to Tools -> Options, type "debugging" into the search box, navigate to the "Output Window" settings and turn "Module Load Messages" Off.

The screenshot below illustrates how find the setting:

DebuggingOptions


2nd Way to disable it

In the Debug Output Window, right-click to bring up the context menu, then un-tick the option as shown below:

ContextMenu


Note: I also turned the Thread Exit Messages off - together with the option above it reduces the noise in the output window significantly!

1
votes

As said before your program runs fine. The output window is just closed on exit.
The info messages you posted mean, that you are currently only debugging your own code (Console.WriteLine("Hello World");) and no framework code.
This is the 'Just my Code' setting. You can change this under Tools>Options>Debugging>General>Enable Just my Code.