启动时Visual Studio Community 2015控制台应用程序错误

时间:2016-02-04 00:21:41

标签: c# visual-studio-2015

以下是错误:

'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).

我可以看到使用ctrl + f5的控制台,我通过另一个堆栈溢出问题找到了它,但它只是在使用Start时运行并消失。 Visual Studio terminates my console application too fast

这是我用C#编写的第一个用于事件驱动编程的程序。我想知道我是否应该担心未来的计划,还是我每次都可以绕过它?我还通过Debug>Options>Debugging>Symbols启用了符号,这会将我的错误从未找到的文件更改为加载的符号。有更好的解决方案吗?我卸载,重新安装,修复,摆脱了可再发行组件,并添加了较旧的可再发行组件但无法找到其他解决方案。任何帮助表示赞赏。

这是代码。

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();
        }
    }
}

1 个答案:

答案 0 :(得分:3)

根本就是不是错误,这是正常 beaviour。

如果启动控制台应用程序,则会显示一个新的控制台窗口,只要您的进程正在运行,它就会保持打开状态。退出流程后,控制台窗口将关闭。

如果您在应用程序的末尾插入Console.ReadKey(),则在您按任意键之前,该窗口将保持打开状态。

所以改变这个......

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

......对此...

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

    Console.ReadKey();
}

... 控制台窗口将保持打开状态,直到您按任意键。

此外:如果要调试.NET框架,符号“启用”将对您有所帮助。它与控制台应用程序的终止将关闭控制台窗口这一事实无关。