我正在尝试调试以下代码

using System;

public class Parent
{
    string parentString;
    public Parent()
    {
        Console.WriteLine("Parent Constructor.");
    }
    public Parent(string myString)
    {
        parentString = myString;
        Console.WriteLine(parentString);
    }
    public void print()
    {
        Console.WriteLine("I'm a Parent Class.");
    }
}

public class Child : Parent
{
    public Child()
        : base("From Derived")
    {
        Console.WriteLine("Child Constructor.");
    }
    public new void print()
    {
        base.print();
        Console.WriteLine("I'm a Child Class.");
    }
    public static void Main()
    {
        Child child = new Child();
        child.print();
        ((Parent)child).print();
    }
}


但是控制台仅在屏幕上闪烁,输出窗口会生成以下消息...


  'ConsoleApplication1.vshost.exe'
  (托管):已加载
  'C:\ Windows \ assembly \ GAC_32 \ mscorlib \ 2.0.0.0__b77a5c561934e089 \ mscorlib.dll'
  'ConsoleApplication1.vshost.exe'
  (托管):已加载
  'C:\ Windows \ assembly \ GAC_MSIL \ Microsoft.VisualStudio.HostingProcess.Utilities \ 9.0.0.0__b03f5f7f11d50a3a \ Microsoft.VisualStudio.HostingProcess.Utilities.dll'
  'ConsoleApplication1.vshost.exe'
  (托管):已加载
  'C:\ Windows \ assembly \ GAC_MSIL \ System.Windows.Forms \ 2.0.0.0__b77a5c561934e089 \ System.Windows.Forms.dll'
  'ConsoleApplication1.vshost.exe'
  (托管):已加载
  'C:\ Windows \ assembly \ GAC_MSIL \ System \ 2.0.0.0__b77a5c561934e089 \ System.dll'
  'ConsoleApplication1.vshost.exe'
  (托管):已加载
  'C:\ Windows \ assembly \ GAC_MSIL \ System.Drawing \ 2.0.0.0__b03f5f7f11d50a3a \ System.Drawing.dll''ConsoleApplication1.vshost.exe'
  (托管):已加载
  'C:\ Windows \ assembly \ GAC_MSIL \ Microsoft.VisualStudio.HostingProcess.Utilities.Sync \ 9.0.0.0__b03f5f7f11d50a3a \ Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll'
  'ConsoleApplication1.vshost.exe'
  (托管):已加载
  'C:\ Windows \ assembly \ GAC_MSIL \ Microsoft.VisualStudio.Debugger.Runtime \ 9.0.0.0__b03f5f7f11d50a3a \ Microsoft.VisualStudio.Debugger.Runtime.dll'
  'ConsoleApplication1.vshost.exe'
  (托管):已加载
  'C:\ Users \ Skylight \ Documents \ Visual
  工作室
  2008 \ Projects \ ConsoleApplication1 \ ConsoleApplication1 \ bin \ Debug \ ConsoleApplication1.vshost.exe'
  'ConsoleApplication1.vshost.exe'
  (托管):已加载
  'C:\ Windows \ assembly \ GAC_MSIL \ System.Core \ 3.5.0.0__b77a5c561934e089 \ System.Core.dll''ConsoleApplication1.vshost.exe'
  (托管):已加载
  'C:\ Windows \ assembly \ GAC_MSIL \ System.Xml.Linq \ 3.5.0.0__b77a5c561934e089 \ System.Xml.Linq.dll''ConsoleApplication1.vshost.exe'
  (托管):已加载
  'C:\ Windows \ assembly \ GAC_MSIL \ System.Data.DataSetExtensions \ 3.5.0.0__b77a5c561934e089 \ System.Data.DataSetExtensions.dll'
  'ConsoleApplication1.vshost.exe'
  (托管):已加载
  'C:\ Windows \ assembly \ GAC_32 \ System.Data \ 2.0.0.0__b77a5c561934e089 \ System.Data.dll''ConsoleApplication1.vshost.exe'
  (托管):已加载
  'C:\ Windows \ assembly \ GAC_MSIL \ System.Xml \ 2.0.0.0__b77a5c561934e089 \ System.Xml.dll'
  线程0x10c8已退出并显示代码
  0(0x0)。线程0x924已退出
  代码为0(0x0)。
  'ConsoleApplication1.vshost.exe'
  (托管):已加载
  'C:\ Users \ Skylight \ Documents \ Visual
  工作室
  2008 \ Projects \ ConsoleApplication1 \ ConsoleApplication1 \ bin \ Debug \ ConsoleApplication1.exe',
  符号已加载。线程0x954具有
  以代码0(0x0)退出。线程
  0xd84已退出,代码为0(0x0)。
  程序“ [3660]
  ConsoleApplication1.vshost.exe:
  托管”已退出,代码为0(0x0)。

最佳答案

问题数量可能导致此:


您设置了断点还是开始
用[F11](进入)?
在调试模式下构建

关于c# - Visual Studio 2008无法调试,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1185745/

10-16 00:07