2009-02-26 7 views
0

Il s'agit d'un projet WinForms C++/CLI qui cible l'infrastructure .NET 2.0. J'utilise Visual Studio 2008. Comment puis-je le faire fonctionner?L'attribut DebuggerDisplay ne fonctionne pas

EDIT: Extrait de code

[Serializable] 
[DebuggerDisplayAttribute(L"ID={EmployeeID}")] 
public ref class Employee 
{ 
    [ReadOnly(true)] 
    int nID; 
    property int EmployeeID 
    { 
     int get() 
     { 
      return nID; 
     } 
    } 
} 
+0

Extrait de code? Qu'est-ce qui échoue? – Brian

+0

Il n'affiche pas le texte personnalisé juste l'habituel: "employee = 0x058482f8 {age = 46 tracker = 0x0584f1cc nID = 14 ...}" –

+0

Maintenant pris en charge dans Update2 VS2015. https://blogs.msdn.microsoft.com/vcblog/2016/02/12/natvis-for-ccli-available-to-preview-in-vs2015-update-2/ – Jordan

Répondre

0

Le consensus est que l'IDE C++ ne le supporte pas.

0

Définir « ne fonctionne pas » ... il fonctionne certainement en C# (je ne sais pas si l'éditeur du C soutient - il suffit de traduire les éléments suivants qui fonctionne en C# pour savoir ;-P)

using System.Diagnostics; 
[DebuggerDisplay("HiWorld={Bar}")] 
class Foo 
{ 
    public string Bar { get; set; } 
    static void Main() 
    { 
     Foo foo = new Foo { Bar = "abc" }; 
     // breakpoint and hover shows: HiWorld="abc" 
    } 
} 

Je ne "fais" C++ plus, mais réflecteur dit:

[DebuggerDisplay(S"HiWorld={Bar}")] 
private __gc class Foo 
{ 
    // Methods 
    private: static void __gc* Main() 
    { 
     Foo __gc* <>g__initLocal0 = __gc new Foo(); 
     <>g__initLocal0->Bar = S"abc"; 
     Foo __gc* foo = <>g__initLocal0; 
    } 


    // Properties 
    [CompilerGenerated] 
    public: __property String __gc* get_Bar() 
    { 
     return this-><Bar>k__BackingField; 
    } 
    [CompilerGenerated] 
    public: __property void __gc* set_Bar(String __gc* value) 
    { 
     this-><Bar>k__BackingField = value; 
    } 


    // Fields 
    [CompilerGenerated] 
    private: String __gc* <Bar>k__BackingField; 
}; 
+0

Autant que je m'en souvienne, Reflector dissimule IL à quelque chose appelé C++ managé qui n'est pas régulier C++/CLI. Ai-je raison? – abatishchev

+0

@abatishchev - certainement géré C++ est l'une des options, mais je ne peux pas commenter comment cela est/n'est pas standard C++/CLI. –

0

Je pense que votre problème est peut-être que vous spécifiez des chaînes étendues (L"ID={EmployeeID}") au lieu de chaînes CLR (S"ID={EmployeeID}"). Alors peut-être changer le L en S et voir comment vous allez?