none
使用visual Studio C#时,Debug功能无法正常运行 RRS feed

  • 问题

  • Hi, 各位,我是一个初学者,在用Visual studio 2013 ultimate 编写Console Application

    Sample代码如下: 

     Console.WriteLine("Input Name");

    使用start without debug ,窗口显示不出字符,只有:"press any key to continue"

    运行debug 无效,报错,很长的一段英文,复制出来,请各位赐教,谢谢!

    'ConsoleApplication2.vshost.exe' (CLR v4.0.30319: ConsoleApplication2.vshost.exe): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_32\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.
    'ConsoleApplication2.vshost.exe' (CLR v4.0.30319: ConsoleApplication2.vshost.exe): Loaded 'C:\windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'ConsoleApplication2.vshost.exe' (CLR v4.0.30319: ConsoleApplication2.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.
    'ConsoleApplication2.vshost.exe' (CLR v4.0.30319: ConsoleApplication2.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.
    'ConsoleApplication2.vshost.exe' (CLR v4.0.30319: ConsoleApplication2.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.
    'ConsoleApplication2.vshost.exe' (CLR v4.0.30319: ConsoleApplication2.vshost.exe): Loaded 'C:\windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\12.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.
    'ConsoleApplication2.vshost.exe' (CLR v4.0.30319: ConsoleApplication2.vshost.exe): Loaded 'C:\windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'ConsoleApplication2.vshost.exe' (CLR v4.0.30319: ConsoleApplication2.vshost.exe): Loaded 'c:\users\johnzhao\documents\visual studio 2013\Projects\ConsoleApplication2\ConsoleApplication2\bin\Debug\ConsoleApplication2.vshost.exe'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'ConsoleApplication2.vshost.exe' (CLR v4.0.30319: ConsoleApplication2.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.
    'ConsoleApplication2.vshost.exe' (CLR v4.0.30319: ConsoleApplication2.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.
    'ConsoleApplication2.vshost.exe' (CLR v4.0.30319: ConsoleApplication2.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.
    'ConsoleApplication2.vshost.exe' (CLR v4.0.30319: ConsoleApplication2.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.
    'ConsoleApplication2.vshost.exe' (CLR v4.0.30319: ConsoleApplication2.vshost.exe): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_32\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.
    'ConsoleApplication2.vshost.exe' (CLR v4.0.30319: ConsoleApplication2.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 0x1e0c has exited with code 259 (0x103).
    The thread 0x3cc8 has exited with code 259 (0x103).
    'ConsoleApplication2.vshost.exe' (CLR v4.0.30319: ConsoleApplication2.vshost.exe): Loaded 'c:\users\johnzhao\documents\visual studio 2013\Projects\ConsoleApplication2\ConsoleApplication2\bin\Debug\ConsoleApplication2.exe'. Symbols loaded.
    The thread 0x3c38 has exited with code 259 (0x103).
    The thread 0x1a18 has exited with code 259 (0x103).
    The thread 0x2d80 has exited with code 259 (0x103).
    The program '[15112] ConsoleApplication2.vshost.exe: Program Trace' has exited with code 0 (0x0).
    The program '[15112] ConsoleApplication2.vshost.exe' has exited with code 0 (0x0).

    请各位帮忙,谢谢!

     
    2014年9月9日 6:17

答案

  • 你好:

    请尝试以下方法:

    1. 关闭VS,到项目目录下面将obj和bin目录删除,打开项目重新编译,然后在DEBUG模式下面调试

    2. 在Debug>Options and Settings...>Enable Just My Code, 反选这个选项

    3. 重置你的VS设置,参考MSDN文档中的步骤:

    http://msdn.microsoft.com/zh-cn/library/ms247075(v=vs.100).aspx

    4. 修复你的VS,进入控制面板,程序和特性,选中Visual Studio,修复


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年9月10日 5:32
    版主
  • 看起来是因为 Optimization 开了。Debugger 在开了 optimization 之后是无法 attach 的。

    请确认:1、Configuration Manager 选了 Debug 而不是 Release;2、Project Properties -> Build 把 Enable Optimization 关掉;3、如果上述均不能解决问题,把 Project Properties -> Debug 里面的 Use VS Host 关掉。


    Mark Zhou

    2014年9月12日 8:45

全部回复

  • 你好:

    请尝试以下方法:

    1. 关闭VS,到项目目录下面将obj和bin目录删除,打开项目重新编译,然后在DEBUG模式下面调试

    2. 在Debug>Options and Settings...>Enable Just My Code, 反选这个选项

    3. 重置你的VS设置,参考MSDN文档中的步骤:

    http://msdn.microsoft.com/zh-cn/library/ms247075(v=vs.100).aspx

    4. 修复你的VS,进入控制面板,程序和特性,选中Visual Studio,修复


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年9月10日 5:32
    版主
  • 看起来是因为 Optimization 开了。Debugger 在开了 optimization 之后是无法 attach 的。

    请确认:1、Configuration Manager 选了 Debug 而不是 Release;2、Project Properties -> Build 把 Enable Optimization 关掉;3、如果上述均不能解决问题,把 Project Properties -> Debug 里面的 Use VS Host 关掉。


    Mark Zhou

    2014年9月12日 8:45