diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ValueNode.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ValueNode.cs
index 289c04417f..cca1163cfd 100644
--- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ValueNode.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ValueNode.cs
@@ -52,7 +52,7 @@ namespace Debugger.AddIn.TreeModel
if (ShowValuesInHexadecimal && val.IsInteger) {
this.Text = String.Format("0x{0:X}", val.PrimitiveValue);
} else {
- this.Text = val.AsString;
+ this.Text = val.AsString;
}
if (val.Type != null) {
@@ -69,6 +69,11 @@ namespace Debugger.AddIn.TreeModel
} else {
this.ChildNodes = null;
}
+
+ // Do last since it may expire the object
+ if (val.IsObject) {
+ this.Text = val.InvokeToString();
+ }
}
public bool CanSetText {
diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Object.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Object.cs
index b9caf601b7..004d7f1838 100644
--- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Object.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Object.cs
@@ -235,6 +235,15 @@ namespace Debugger
);
}
+ /// Invoke the ToString() method
+ public string InvokeToString()
+ {
+ if (!IsObject) {
+ throw new DebuggerException("ToString can be only invoked on object");
+ }
+ return Eval.InvokeMethod(Process, typeof(object), "ToString", this, new Value[] {}).AsString;
+ }
+
#region Convenience overload methods
/// Asynchronously invoke the method
diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.cs
index f60fe5e573..674ba5700a 100644
--- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.cs
@@ -45,10 +45,9 @@ namespace Debugger
/// Gets a string representation of the value
public string AsString {
get {
- if (IsNull) return "";
+ if (IsNull) return "null";
if (IsArray) return "{" + this.Type.FullName + "}";
if (IsObject) return "{" + this.Type.FullName + "}";
- //if (IsObject) return Eval.InvokeMethod(Process, typeof(object), "ToString", this, new Value[] {}).AsString;
if (IsPrimitive) return PrimitiveValue != null ? PrimitiveValue.ToString() : String.Empty;
throw new DebuggerException("Unknown value type");
}