开发者

QuickWatch Fails and Debugging Stops When Trying to View Custom Object

开发者 https://www.devze.com 2023-02-16 10:56 出处:网络
I have a Branch object that has some Name, Link and a few other POCO properties.It also has a Parent object that is a link to another Branch item.It also has a Children property that is a TreeBranches

I have a Branch object that has some Name, Link and a few other POCO properties. It also has a Parent object that is a link to another Branch item. It also has a Children property that is a TreeBranches object. This is an IList. This essentially is my replacement for the TreeNode.

While debuggin my application I can stop on breakpoints anywhere and QuickWatch any Other object a开发者_高级运维s nested as possible. They all work. However, when I QuickWatch a Branch object it shows me a the "root" item. When I try to go to any child Branches it pauses for a moment and then all values are no longer ... live? Meaning I can no long click the refresh button. When I close out of the QuickWatch window I see that my website is on a page as if I can't connect to the website. I can't even continue by hitting F5.

I have made plenty of objects in my career and I could "watch" them all. Is there some special attribute I should apply? Is there some error log somewhere I can see what the problem is? I have set it to break on "thrown" errors for the CLR Exceptions but nothing. Perhaps because I am already in a "break."

The only other thing that "may" be an issue is that I have overridden the ToString method on the Branch object to show the propeties on the Branch and the count of Children. Then the TreeBranches object also has a ToString method that recursively loops through each of the Branch objects.

Any thoughts?


I suppose this doesn't happen if you uncheck the "Enable property evaluation and other implicit function calls" in Tools->Options->Debugging?

When things stop working, does the text "Function evaluation disabled because a previous function evaluation timed out. You must continue execution." show up?

If so, I'm willing to bet that your ToString implementation is buggy and goes into an infinite loop, or just has a performance issue and takes too long. Try replacing those .ToStrings with "return string.Empty;" and see if the problem persists?

Unlike method calls, the debugger assumes that an object's .ToString of an object is supposed to return quickly and not have side effects, and will therefore re-evaluate it every time you F5 and break, while the object is still in the Watch window.

If it's not the .ToString, it might be some property on the object that is doing a lot of work and timing out - check if such a property exists on your object, and consider decorating it with [DebuggerBrowsable(DebuggerBrowsableState.Never)].

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号