CLR exceptions are due to .Net Business connector.
when AX tried to call something by reflection but the called method threw an exception.
To understand what failed, you should find what was called and what was the exception.
1. Catch the exception (by catch (Exception::CLRError)).
2. Get the CLR exception and look into its InnerException property.
AifUtil::getClrErrorMessage()
is usually the easiest way to do that.
Eg:
static void RaiseCLRException(Args _args)
{
;
//Necessary if executed on the AOS new InteropPermission(InteropKind::ClrInterop).assert();
try
{
//This will cause an exception
System.Int32::Parse("abc");
}
catch(Exception::CLRError)
{
AifUtil::getClrErrorMessage();
//Access the last CLR
Exception info(CLRInterop::getLastException().ToString());
}
//Revert CAS back to normal CodeAccessPermission::revertAssert();
}
when AX tried to call something by reflection but the called method threw an exception.
To understand what failed, you should find what was called and what was the exception.
1. Catch the exception (by catch (Exception::CLRError)).
2. Get the CLR exception and look into its InnerException property.
AifUtil::getClrErrorMessage()
is usually the easiest way to do that.
Eg:
static void RaiseCLRException(Args _args)
{
;
//Necessary if executed on the AOS new InteropPermission(InteropKind::ClrInterop).assert();
try
{
//This will cause an exception
System.Int32::Parse("abc");
}
catch(Exception::CLRError)
{
AifUtil::getClrErrorMessage();
//Access the last CLR
Exception info(CLRInterop::getLastException().ToString());
}
//Revert CAS back to normal CodeAccessPermission::revertAssert();
}
No comments:
Post a Comment