Throw exception in the line where the method is called
When i use the Math library. like this.
14- 开发者_如何学运维 int Result = 0;
15- Math.DivRem(1, 0, out Result);
The exception is marked in the line 15, but if i use my own Math Library, like this.
class MyMath
{
public static decimal DivRem(int a, int b)
{
return a / b;
}
}
and then call it.
14- int Result = 0;
15- MyMath.DivRem(1, 0);
The error is market inside my static DivRem in the line "return a / b;"
How can i achieve that?
ideas? thanks.
Put your own math library in a separate assembly where the calling assembly only references the compiled release version.
Take a look at this question. The PDB seems to hold the debug information you would need to get those line numbers. Since I doubt there are PDB files for all the classes in the .NET framework, I think you are out of luck. I may be wrong, and they may be available, but at least you know what to look for now.
You can instruct the debugger to step through (rather than into) the method with an attribute; I suspect this will also cause it to show the Exception at the call site, but I'm not certain.
class MyMath
{
[DebuggerStepThrough]
public static decimal DivRem(int a, int b)
{
return a / b;
}
}
精彩评论