Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Community 2015 Console Application Error on Start

Here are the errors:

'ConsoleApplication3.vshost.exe' (CLR v4.0.30319: ConsoleApplication3.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleApplication3.vshost.exe' (CLR v4.0.30319: ConsoleApplication3.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleApplication3.vshost.exe' (CLR v4.0.30319: ConsoleApplication3.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleApplication3.vshost.exe' (CLR v4.0.30319: ConsoleApplication3.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleApplication3.vshost.exe' (CLR v4.0.30319: ConsoleApplication3.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleApplication3.vshost.exe' (CLR v4.0.30319: ConsoleApplication3.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleApplication3.vshost.exe' (CLR v4.0.30319: ConsoleApplication3.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleApplication3.vshost.exe' (CLR v4.0.30319: ConsoleApplication3.vshost.exe): Loaded 'C:\Users\Chris James\Documents\Visual Studio 2015\Projects\ConsoleApplication3\ConsoleApplication3\bin\Debug\ConsoleApplication3.vshost.exe'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleApplication3.vshost.exe' (CLR v4.0.30319: ConsoleApplication3.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleApplication3.vshost.exe' (CLR v4.0.30319: ConsoleApplication3.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleApplication3.vshost.exe' (CLR v4.0.30319: ConsoleApplication3.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleApplication3.vshost.exe' (CLR v4.0.30319: ConsoleApplication3.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleApplication3.vshost.exe' (CLR v4.0.30319: ConsoleApplication3.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleApplication3.vshost.exe' (CLR v4.0.30319: ConsoleApplication3.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 0x3344 has exited with code 0 (0x0).
The thread 0x369c has exited with code 0 (0x0).
The thread 0x4498 has exited with code 0 (0x0).
'ConsoleApplication3.vshost.exe' (CLR v4.0.30319: ConsoleApplication3.vshost.exe): Loaded 'c:\users\chris james\documents\visual studio 2015\Projects\ConsoleApplication3\ConsoleApplication3\bin\Debug\ConsoleApplication3.exe'. Symbols loaded.
'ConsoleApplication3.vshost.exe' (CLR v4.0.30319: ConsoleApplication3.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Accessibility\v4.0_4.0.0.0__b03f5f7f11d50a3a\Accessibility.dll'. Symbols loaded.
The thread 0x2b58 has exited with code 0 (0x0).
The thread 0x3994 has exited with code 0 (0x0).
The program '[11144] ConsoleApplication3.vshost.exe' has exited with code 0 (0x0).

I can see the console using ctrl + f5 which I found out through another stack overflow question, but it runs and disappears when just using Start. Visual Studio terminates my console application too fast

This is my first program written in C# for event driven programming. I was wondering if I should be worried about future programs or can I bypass it everytime? I also enabled Symbols through Debug>Options>Debugging>Symbols, which changed my error from file not found to symbol loaded. Is there a better fix? I uninstalled, reinstalled, repaired, got rid of redistributables, and added older redistributables but couldn't find another solution. Any help is appreciated.

Here is the code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DelegateTutorial1
{
    public class MediaStorage
    {
        public delegate int PlayMedia();

        public void ReportResult(PlayMedia playerDelegate)
        {
            if (playerDelegate() == 0)
            {
                Console.WriteLine("Media played successfully");
            }
            else
            {
                Console.WriteLine("Media did not play successfully");
            }
        }
    }

    public class AudioPlayer
    {
        private int audioPlayerStatus;

        public int PlayAudioFile()
        {
            Console.WriteLine("Simulating playing an audio file");
            audioPlayerStatus = 0;
            return audioPlayerStatus;
        }
    }

    public class VideoPlayer
    {
        private int videoPlayerStatus;

        public int PlayVideoFile()
        {
            Console.WriteLine("Simulating a failed video file");
            videoPlayerStatus = -1;
            return videoPlayerStatus;
        }
    }

    public class Tester
    {
        public void Run()
        {
            MediaStorage myMediaStorage = new MediaStorage();
            AudioPlayer myAudioPlayer = new AudioPlayer();
            VideoPlayer myVideoPlayer = new VideoPlayer();

            MediaStorage.PlayMedia audioPlayerDelegate = new MediaStorage.PlayMedia(myAudioPlayer.PlayAudioFile);
            MediaStorage.PlayMedia videoPlayerDelegate = new MediaStorage.PlayMedia(myVideoPlayer.PlayVideoFile);

            myMediaStorage.ReportResult(audioPlayerDelegate);
            myMediaStorage.ReportResult(videoPlayerDelegate);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Tester t = new Tester();
            t.Run();
        }
    }
}
like image 805
ChrisFocker Avatar asked Oct 19 '22 16:10

ChrisFocker


1 Answers

That's not an error at all, that's the normal beaviour.

If you start a console application, a new console window is shown and it will stay open as long as your process is running. Once your process has exited, the console window will be closed.

If you insert Console.ReadKey() at the end of your application, the window will stay open until you press any key.

So change this...

static void Main(string[] args)
{
    Tester t = new Tester();
    t.Run();
}

...to this...

static void Main(string[] args)
{
    Tester t = new Tester();
    t.Run();

    Console.ReadKey();
}

...and the console window will stay open until you press any key.

In addition: The symbols you "enabled" will help you if you want to debug into the .NET framework. It has nothing to do with the fact that the termination of the console application will close the console window.

like image 175
Markus Safar Avatar answered Nov 15 '22 04:11

Markus Safar