开发者

Visual Studio 2008 debugger - function evaluation weirdness

I'm developing a plugin for a bigger app and I encountered a strange problem with the following code. When run in Release mode or in Debug with no breakpoints everything is fine. But when I put a breakpoint somewhere near the snippet below I get an error. It looks like debugger pre-evaluates the code inside the if blocks causing an error altough this code is never actually reached.

Please note that the indexer internally checks for incorrect indexes and fires an event way up to the main applicati开发者_JAVA百科on. The main app handles this error event by showing a dialog box and closing itself. I can't change the main app and I can't modify the indexer (altough I think throwing an exception instead of firing an event could work).

int a = GetA(); // returns 0
if (a == 1)
{
   _manager[a - 1][ColumnName.Name] = "X"; //Manager has an indexer returning a DataRow.
}

if (a == 2)
{
   _manager[a - 1][ColumnName.Name] = "Y";
}

When I disabled the "Enable property evaluation and other implicit function calls" in Tools->Options->Debugging it worked perfectly. Do you have any ideas how to work-around this? I don't want this error messages but I also don't want to lose the debugger evaluation convenience.

[EDIT] I re-wrote the description.

[UPDATE] I temporarily changed the code inside the indexer to throw an exception insted of delegating an event to the upper error-handling layer and it helped. VS debugger swallowed the exception so all side effects stopped (no message boxes were displayed by the error handling layer)

So the question is:

Is there a third option beside:

1) Permanently changing from an event being popped-up to upper layer to an exception

2) Unchecking 'Enable property evaluation and other implicit function calls'


Do you control the implementation of the class that _manager is an instance of? HAve you tried putting [DebuggerBrowsable(Never)] attribute on it? It should hide that property from the debugger.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜