N
news.microsoft.com
Hi all.
If I wanted to write something so that, when an exception was thrown, and
the stack unwound, the stack trace was captured with the values of the
parameters (instead of just the parameter signature for method), is this
possible without exception-wrapping the guts of each method?
I can see how to get parameter values out of MethodInfo, but can't see how
to do it without doing something like adding 7 lines to each method, taking
the following code:
public void myMethod( Class1 object1 )
{
object1.doSomething()
}
and turning it into:
public void myMethod( Class1 object1 )
{
try
{
object1.doSomething()
}
catch (Exception e )
{
throw new CustomException( MethodInfo, e )
}
}
I thought of using attributes, but can't see a way to do it. I also thougth
of using a using block, which is 3 lines instead of 7, but I can't figure
how to do this either.
Is anybody smart out there who knows how to do this in C#? I miss c++
macros, for this particular purpose.
Cheers,
Steve.
If I wanted to write something so that, when an exception was thrown, and
the stack unwound, the stack trace was captured with the values of the
parameters (instead of just the parameter signature for method), is this
possible without exception-wrapping the guts of each method?
I can see how to get parameter values out of MethodInfo, but can't see how
to do it without doing something like adding 7 lines to each method, taking
the following code:
public void myMethod( Class1 object1 )
{
object1.doSomething()
}
and turning it into:
public void myMethod( Class1 object1 )
{
try
{
object1.doSomething()
}
catch (Exception e )
{
throw new CustomException( MethodInfo, e )
}
}
I thought of using attributes, but can't see a way to do it. I also thougth
of using a using block, which is 3 lines instead of 7, but I can't figure
how to do this either.
Is anybody smart out there who knows how to do this in C#? I miss c++
macros, for this particular purpose.
Cheers,
Steve.