i have a base class that accepts a StackFrame
parameter.
public ExcpM(string Msg, StackFrame parCallStack = null, bool show = true)
{
StackFrame LcallStack;
if (parCallStack == null)
LcallStack= new StackFrame(1, true);
else LcallStack= parCallStack;
//do stuff with info in LcallStack ..
}
originally i have started without the said parameter, i have added it because
when using a common Extension method or any method that calls the above constructor,
without the added parameter callStack.GetMethod()
will then give the extension method data rather the intended caller which is the one i was after.
now that i called it as a solution, there comes a new problem that i am stuck without a proper solution for, which starts me thinking i am using it incorrectly.
the problem is when i created a derived class from the above ExcpM
main class
which also gives the wrong guy data (the derived own ctor..)
derived (added a false return value for Boolean methods usage)
public class ExcpFlsV:ExcpM
{
bool Rtrn { get { return false; } }
public ExcpFlsV(string bsMsg, StackFrame bsCallStack = null)
: base(bsMsg, bsCallStack)
{
}
}
usage
public bool someMethodReturnsBool()
{
//unless adding Local callStack field to every method passes ctor of ExcpFlsV as calling method
StackFrame LcallStack = new System.Diagnostics.StackFrame(1, true);
if(some condition no met)
return new ExcpFlsV("some error message...", LcallStack).Rtrn;
}
what is the proper way to pass the caller method as the data ?