Visual Studio意外停止调试且没有错误 [英] Visual Studio stops debugging with no errors unexpectedly
问题描述
我正在调试一个项目,Visual Studio停止调试并在没有异常或错误消息的情况下在下一行关闭程序(我已在选项中对任何引发的异常启用了通知):
I am debugging a project and Visual Studio stops debugging and closes the program on the following line with no exceptions or error messages (I have enabled notifications for any thrown exceptions in options):
var query = Session.Linq<RSS>()
.Where(x => x.LastRetrieved <= date || x.LastRetrieved == null)
.Where(x => x.Moderated);
其中Session.Linq指的是LINQ2NHibernate.无论如何,问题是:这种行为的可能原因是什么?在VS 2010和2008上都进行了测试-它们的行为完全相同,只是出于调试目的.
Where Session.Linq refers to LINQ2NHibernate. Anyway, the question is: what are the possible reasons for such behavior? Tested both on VS 2010 and 2008 - they behave identically just falling out of debugging.
更新.如果我将应用程序类型更改为控制台应用程序",则其行为正常.很奇怪.
Update. If I change application type to "Console Application" it behaves normally. Very strange.
推荐答案
我也遇到了类似的问题,尽管这可能不是您上述情况的解决方案,但我希望它能对那里的其他人有所帮助.
I had a similar problem and although this might not be a solution for your case above, I hope it will help someone else out there.
我必须引用一个由其他人编写的类,如下所示:
I had to reference a class that was written by someone else that looked like this:
public class ItemPrice
{
public bool sucessIndicator
{
get { return sucessIndicator; }
set { sucessIndicator = value; }
}
public string productCode
{
get { return productCode; }
set { productCode = value; }
}
public string description
{
get { return description; }
set { description = value; }
}
public double price
{
get { return price; }
set { price = value; }
}
}
乍一看,它看起来还不错……直到您注意到每个属性都引用了它自己而不是私有成员.
At first glance it looks ok right... until you notice that each property is referencing it self and not a private member.
所以:
public string description
{
get { return description; }
set { description = value; }
}
自我递归地引用它,并导致堆栈溢出异常,即使我启用了所有异常,该异常也没有在VS中显示给我.它只是在没有警告的情况下停止了调试.
is referencing it self recursively and causes a stack overflow exception that did not get shown to me in VS even though I had all exceptions enabled. It just stopped debugging with no warning.
解决方案当然是要像这样更改它:
The solution was of course to change it more like this:
public string description
{
get;
set;
}
希望能帮助到某人.
这篇关于Visual Studio意外停止调试且没有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!