【发布时间】:2012-01-24 15:05:48
【问题描述】:
此行导致PostEntityImages 集合中出现“未找到密钥”。
Entity pimage = _context.PostEntityImages["postcreate"];
当我在该行上放一个断点并将其放在监视窗口中时,它可以正常工作并且该键 存在。
更新:
protected override void ExecutePlugin()
{
try
{
Entity pimage = null;
if (_context.PostEntityImages.ContainsKey("postcreate"))
pimage = _context.PostEntityImages["postcreate"];
}
catch (Exception)
{
// Never hits this line
throw;
}
} // When stepping in/over the line assigning pimage, execution will jump to this point, then be caught in the catch block of this methods caller.
更新 #2:
在调试模式下,一些断点设置得很好。其他给出错误“无法设置以下断点:”
【问题讨论】:
-
你检查了大写、小写的拼写吗? ContainsKey 返回什么?真假?
-
此外,在调试器中检查变量值可以触发其他代码,例如使用后期绑定时。
-
我同意,案例是我的第一选择。
-
@MBen _context.PostEntityImages.ContainsKey("postcreate") 返回真。我直接从代码窗口复制到监视窗口中。
-
所以也许你应该尝试这样做:PostEntityImages.TryGetValue ("postcreate", out entity);
标签: c# .net visual-studio-2010 clr dynamics-crm-2011