Hi folks,
Sometimes you want to debug a process in AX2012 but it’s running in batch and you don’t want to setup up batch debugging.
In this case you can add a throw to the code to check the value of a variable, but even if you do this you won’t be able to know what was the caller.
So, here is a sample code to get the current call stack:
System.Diagnostics.StackTrace myStackTrace = new System.Diagnostics.StackTrace(true);
System.Exception ex;
str callStack;
if (xSession::isCLRSession())
{
try
{
callStack = myStackTrace.ToString();
}
catch
{
ex = ClrInterop::getLastException();
if (ex != null)
{
ex = ex.get_InnerException();
if (ex != null)
{
info(ex.ToString());
}
}
}
}
else
{
callStack = con2Str(xSession::xppCallStack());
}
throw info(callStack);
0 Comments