调试时无法设置下一条语句 [英] Unable to set next statement when debugging

查看:771
本文介绍了调试时无法设置下一条语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在VS2015中调试我的项目,并且在我的代码中引发了异常。
当我尝试设置下一条语句时,出现以下错误信息。当我在VS2013中调试相同的解决方案时,我可以设置下一条语句而不会出现任何问题。

I am debugging my project in VS2015 and an exception is thrown in my code. When I try to set the next statement I get the error message displayed below. When I debug the same solution in VS2013 I am able to set the next statement without any problems. This behavior seems to occur for multiple kinds of exceptions.

我可以重现该问题的示例代码如下所示。当在 TestMethod1 的最后一行抛出异常时,我可以轻松地移回VS2013中的第一条语句,而不能回到VS2015中。

Example code that I can reproduce the problem with is shown below. When an exception is thrown on the last line in TestMethod1 I can easily move back to the 1st statement in VS2013 but not in VS2015.

[TestClass]
public class UnitTest1
{
    [TestMethod]
    public void TestMethod1()
    {
        object o = new object();
        o = null;
        var e = o.ToString();
    }
}


推荐答案

在在例外设置中,您需要为要抛出的特定CLR例外类型启用抛出时中断,或者<不在此列表中的所有公共语言运行时例外。自定义例外。在此特定示例中,启用 System.NullReferenceException 应该允许您按预期设置下一条语句。

In Exception Settings, you need to enable Break When Thrown for the particular CLR exception type that is being thrown, or <All Common Language Runtime Exceptions not in this list> for custom exceptions. In this particular example, enabling System.NullReferenceException should allow you to set next statement as expected.

您希望在不破坏所有未列出的CLR异常的情况下打破的特定自定义异常,可以将它们添加到异常设置中的列表中,并进行相应选择。

If there are particular custom exceptions you want to break on without breaking on all unlisted CLR exceptions, you can add them to the list in Exception Settings and choose accordingly.

我在MSDN并从那里中继信息。 []

I asked about this on MSDN and am relaying info from there. [Source]

这篇关于调试时无法设置下一条语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆