简体   繁体   中英

Show exception message when debugging a property that throws an exception

In the following code:

class MyClass
{
    public int MyProperty
    {
        get
        {
            throw new InvalidOperationException("A message from this exception...");
        }
    }
}

class Program
{
    static void Main(string[] args)
    {
        var c = new MyClass();
        var i = c.MyProperty;
    }
}

If you hover over c when debugging, you see the following:

在此处输入图片说明

Is there a way to show the actual exception message somehow?

You can bring up the QuickWatch window (right-click on the variable while debugging and select QuickWatch on the context menu) and expand the property:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM