【发布时间】:2013-07-23 01:29:19
【问题描述】:
在单步执行我的代码时,我发现某些深层忽略了 DebuggerStepThrough 属性的行。它似乎是 for within linq 语句。
这是一个类似的 SO:DebuggerStepThrough being ignored
单步执行的代码处于调试模式。它与下面的 ReflectionHelper 方法在同一个解决方案中。项目引用是通过项目而不是其他地方的编译 dll,即与项目相同的输出 bin/debug 文件夹。没有发生其他异常情况,这可能表明正在使用的程序集与在项目双方进行代码更改时会注意到的不同。
所以当我逐步使用 F11 时,它会进入下面的代码。
我的public static class ReflectionHelper中有以下内容
[DebuggerStepThrough]
public static bool Exists(string propertyName, object srcObject)
{
PropertyInfo propInfoSrcObj = srcObject.GetType().GetProperties()
.FirstOrDefault(p => p.Name == propertyName); //-- Debugger stops here
return (propInfoSrcObj != null);
}
如何避免此代码单步执行?我目前的解决方法是 SHIFT+F11 在使用 F11 恢复调试之前退出。
发生这种情况的另一个例子是这段代码。
string databaseNamePair = split.Find(f => f.StartsWith("Initial Catalog"));
【问题讨论】:
标签: c# visual-studio-2010 linq debugging breakpoints