Debugger behaviour changes between vs2008 and vs2010
I'm struggling with the behavioural difference between the visual studio 2008, and 2010 debugger.
In 2008, with the debugger attached, the code below would not stop to show an unhandled exception at the property setter of I in object a. (Menu Option : Debug/Exceptions, user-unhandled on, and option "Thrown" off)
The try catch block would catch the targetInvocationException, and I would开发者_如何学运维 be free to safely ignore it (in a special case, mind you).
However, in vs 2010, this code, with the debugger attached, will break at the failed attempt to set value I. (which is annoying for my collegues, as I don't want their debug runs to suddenly stop because of this).
As far as I have figured out, I have the option to apply attribute "System.Diagnostics.DebuggerNonUserCode" on the class, or to disable the debug option "Enable just my code".
The first option isn't really a viable one, because in the real world, class A is generated (with hundreds of others) And I can't oversee what disabling option "enable just my code" will have for effect on our multiple, big solutions.
Can someone explain to me why disabling the just my code option makes a difference here ?
Thanks in advance! ;)
p.s I have also tried disabling all the reflection unhandled options in Debug/Exceptions/Common language runtime exceptions, system.Reflections, but that seemed to have no effect...
-- example code --
using System;
using System.Reflection;
class A
{
public int I { set { throw new Exception("Sorry, no can do"); } }
}
class Program
{
static void Main()
{
PropertyInfo targetMember = typeof(A).GetProperty("I");
var a = new A();
try
{
targetMember.SetValue(a, 1, null);
}
catch (TargetInvocationException)
{
// happy to ignore this, lalala
}
}
}
精彩评论