【发布时间】:2015-04-23 15:47:48
【问题描述】:
我有一个使用 Entity Framework Code First 的小型 ASP.NET MVC5 项目。我在控制器中放置了一个断点,以便我可以检查变量的内容,以确保它们都包含它们应该包含的内容。一个这样的变量是我从上下文中查询的复杂模型对象,当我尝试扩展该对象以查看其属性时,调试器只是简单地关闭而没有明显的错误消息。我得到的唯一解释是在输出中:
The program '[10820] iisexpress.exe: Program Trace' has exited with code 0 (0x0). The program '[10820] iisexpress.exe' has exited with code -2147023895 (0x800703e9). The program '[12128] iexplore.exe' has exited with code -1 (0xffffffff).
我查看了退出代码 -2147023895 (0x800703e9),发现这是一个堆栈溢出问题,实际上无助于找出导致它的原因。
最不寻常的是,如果我让应用程序运行,它会毫无问题地加载页面,而且似乎根本不会抛出任何错误。这是怎么回事?
这是我的相关代码:
控制器
public ActionResult Index()
{
//This is the line that crashed the debugger if I try to expand quarter
//after it is filled. There will only ever by one item marked isCurrent.
Quarter quarter = db.Quarter.First(x => x.isCurrent == true);
...
}
型号
public class Quarter
{
public int Id {get; set;}
public Enums.QuarterEnum Quarter {get; set;}
public string Year {get; set;}
public bool isCurrent {get; set;}
[NotMapped]
public string QuarterAndYear {get{ return QuarterAndYear; }}
}
查看
...
@Html.LabelFor(model => model.Quarter.Quarter)
@Html.DisplayFor(model => model.Quarter.Quarter)
...
【问题讨论】:
标签: c# asp.net-mvc entity-framework debugging visual-studio-2013