using System;
using System.Diagnostics;
class App
{
static void Main(string[] args)
{
try
{
throw new MyDerivedException("Hello");
}
catch
{
}
}
}
class MyBaseException : ApplicationException
{
public MyBaseException(string msg)
:base(msg)
{
}
}
class MyDerivedException : MyBaseException
{
public MyDerivedException(string msg)
:base(msg)
{
StackFrame sf = new StackFrame(1);
Console.WriteLine(sf.GetMethod().ReflectedType.FullName);
}
}
Prints out "App" for me. Can you post a short and complete example that demonstrates what you are seeing. If its an exception, the fact that using the StackFrame is slow should be irrlevant as it should only get called rarely in exceptional situations. I ran this without the debugger and its not obviously very slow.
Regards
Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<
[email protected]>
Hi Richard,
It's not exactly good for me.
I created an exception class ‘expA' derived from ApplicationException.
And there is an exception class ‘expB' derived from ‘expA'.
Now class C application is throwing ‘expB'.
I want ‘expB' to know how the class is the ctreated and throw him.
After trying you lines, I get the class ‘expA' and it's taking very very
long time.