2009-07-26 15 views
2

Im essayant de déboguer le code suivantVisual Studio 2008 ne serait pas déboguer

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

mais la console ne clignote sur l'écran, la fenêtre de sortie génère les messages suivants ...

« ConsoleApplication1 .vshost.exe ' (géré): chargé 'C: \ Windows \ assembly \ GAC_32 \ mscorlib \ 2.0.0.0__b77a5c561934e089 \ mscorlib.dll' 'ConsoleApplication1.vshost.exe' (géré): chargé ' C : \ Windows \ assembl y \ GAC_MSIL \ Microsoft.VisualStudio.HostingProcess.Utilities \ 9.0.0.0__b03f5f7f11d50a3a \ Microsoft.VisualStudio.HostingProcess.Utilities.dll ' ' ConsoleApplication1.vshost.exe ' (Géré): chargé ' C: \ Windows \ assembly \ 'GAC_MSIL \ System.Windows.Forms \ 2.0.0.0__b77a5c561934e089 \ System.Windows.Forms.dll' 'ConsoleApplication1.vshost.exe' (Géré): chargé 'C: \ Windows \ assembly \ GAC_MSIL \ System \ 2.0. 0.0__b77a5c561934e089 \ System.dll ' ' ConsoleApplication1.vshost.exe ' (Géré): chargé ' C: \ Windows \ assembly \ GAC_MSIL \ System.Drawing \ 2.0.0.0__b03f5f7f11d50a3a \ System.Drawing.dll '' ConsoleApplication1. vshost.exe ' (Géré): chargé ' C: \ Windows \ assembly \ GAC_MSIL \ Microso ft.VisualStudio.HostingProcess.Utilities.Sync \ 9.0.0.0__b03f5f7f11d50a3a \ Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll ' 'ConsoleApplication1.vshost.exe' (Managed): Loaded' C: \ Windows \ assembly \ 'C: \ Users \ Skylight \ Documents \' visuel studio 2008 \ Projects \ ConsoleApplication1 \ ConsoleApplication1 \ bin \ Debug \ ConsoleApplication1.vshost.exe ' 'ConsoleApplication1.vshost.exe' (géré): Chargé ' C: \ Windows \ assembly \ GAC_MSIL \ System.Core \ 3.5.0.0__b77a5c561934e089 \ System.Core.dll ' 'ConsoleApplication1.vshost.exe' (Managed): Chargé 'C: \ Windows \ assembly \ GAC_MSIL \ System.Xml.Linq \ 3.5.0.0__b77a5c561934e089 \ System.Xml.Linq.dll' 'ConsoleApplication1.vshost.exe' (géré): chargé 'C: \ Windows \ assembly \ GAC_MSIL \ System.Data.DataSetExtensions \ 3.5.0.0__b77a5c561934e089 \ System.Data.DataSetExtensions.dll' 'ConsoleApplication1.vshost.exe' (géré): Loaded 'C: \ Windows \ assembly \ GAC_32 \ System.Data \ 2.0.0.0__b77a5c561934e089 \ System.Data.dll' 'ConsoleApplication1.vshost.exe' (Géré): chargé 'C: \ Windows \ assembly \ GAC_MSIL \ System.Xml \ 2.0.0.0__b77a5c561934e089 \ System.Xml.dll ' Le thread 0x10c8 s'est terminé avec le code 0 (0x0). Le thread 0x924 a quitté avec le code 0 (0x0). 'ConsoleApplication1.vshost.exe' (géré): Chargé 'C: \ Users \ Skylight \ Documents \ de Visual Studio de 2008 \ Projects \ ConsoleApplication1 \ ConsoleApplication1 \ bin \ Debug \ ConsoleApplication1.exe', symboles chargés. Le thread 0x954 a quitté avec le code 0 (0x0). Le thread 0xd84 s'est terminé avec le code 0 (0x0). Le programme '[3660] ConsoleApplication1.vshost.exe: Managed' a quitté avec le code 0 (0x0).

+1

Question stupide, avez-vous défini votre point d'arrêt n'importe où? En outre, quelle configuration de construction utilisez-vous? Déboguer/Relâcher? –

Répondre

5

Nombre de problèmes peuvent causer ceci:

  1. Avez-vous mis un point d'arrêt ou commencer avec [F11] (pas dans)?
  2. build en mode débogage
4

Si vous voulez que la console pour rester, mettez un ...

Console.ReadLine(); 

... comme la dernière ligne de votre Main. Il restera ouvert jusqu'à votre retour. (Cela ressemble à un petit programme de test pour moi, donc je pense que cela irait bien.)

Questions connexes