Is there any way to get the error message that is thrown from x++ code when it is caught in C# code? There are a lot of articles about how to handle a CLR exception from X++ code. However, I am unable to find anything to explain how I can handle an X++ error that is thrown to .NET code.
I am working in AX 2012. I have added a .NET project under the AOT > Visual Studio Projects > C Sharp Projects. In this C# project, my .NET code calls into an X++ class. The X++ method throws an error. When the error is thrown, I can see in the visual studio debugger that it is of type Microsoft.Dynamics.Ax.Xpp.ErrorException. The message in this exception is "Exception of type 'Microsoft.Dynamics.Ax.Xpp.ErrorException' was thrown."
Back in the .NET code, the exception is caught as a System.Reflection.TargetInvocationException where the inner exception is the Microsoft.Dynamics.AX.Xpp.ErrorException. Is there no way to get the error message that was thrown from x++ code when it is caught in the C# code?
Any help would be greatly appreciated!
*This post is locked for comments