diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs index b20fcf2c10..ae9df1754b 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs @@ -197,20 +197,23 @@ namespace ICSharpCode.SharpDevelop.Services { if (debugger == null || debugger.IsRunning) return null; VariableCollection collection = debugger.LocalVariables; - if (collection == null) + if (collection == null) { return null; - foreach (Variable v in collection) { - if (v.Name == variableName) { - object val = v.Value; - if (val == null) - return ""; - else if (val is string) - return "\"" + val.ToString() + "\""; - else - return val.ToString(); - } } - return null; + + object val; + try { + val = collection[variableName].Value; + } catch (DebuggerException) { + return null; + } + if (val == null) { + return ""; + } else if (val is string) { + return "\"" + val.ToString() + "\""; + } else { + return val.ToString(); + } } public void Dispose() diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs index 7bbec6b846..20fa65f982 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs @@ -68,9 +68,16 @@ namespace DebuggerLibrary public Variable this[string variableName] { get { - foreach (Variable v in InnerList) { - if (v.Name == variableName) { - return v; + int index = variableName.IndexOf('.'); + if (index != -1) { + string rootVariable = variableName.Substring(0, index); + string subVariable = variableName.Substring(index + 1); + return this[rootVariable].SubVariables[subVariable]; + } else { + foreach (Variable v in InnerList) { + if (v.Name == variableName) { + return v; + } } }