在VS2010 SP1中调试迭代器方法(具有调试设置.没有编译器优化),我的变量之一,操作数,“在当前上下文中不存在”,根据Quick在“立即”窗口(如果我鼠标在变量上也不会弹出)。
变量在作用域中。
关于什么可能导致炎症或者如何避免它的想法?
private IEnumerable<Answer> CreateVirtualFormulaAnswers(Question question, List<Answer> answers)
{
string[] formulaParts = question.Formula.Split(FORMULA_SPLIT, StringSplitOptions.None);
string formula = formulaParts[0].Trim();
if (formulaParts.Length != 2) throw new Exception("Formula format is incorrect: " + question.Formula);
// At this point:
// formulaParts.Length = 2
// formulaParts has a non-null string at each index
// Mouse over of "op" in VS2010 debugger does not show any popup
// Quick watch and immediate window both state: "The name 'operand' does not exist in the current context"
string operand = formulaParts[1].Trim();
string answerText = (from a in answers where a.QuestionCode == op select a.Text).SingleOrDefault();
if (answerText != null)
{
yield return new Answer()
{
/* Initialization code here based on formula */
};
}
}发布于 2012-03-25 20:51:44
正如都铎所言,这似乎是VS 2010 SP1的一个限制。
我发现,在调试器实际被代码使用之前,操作数对调试器是不可见的,而不仅仅是通过赋值点。
具体地说:
Debug.WriteLine(operand);正确打印到控制台。
此外,一旦操作数被Linq语句的where子句计算,Quick和即时窗口就会突然了解它。
https://stackoverflow.com/questions/9863829
复制相似问题