Getting the exception type from the GETLASTERROROBJECT

  • Post comments:4 Comments
  • Reading time:6 mins read

In my last post I have introduced the GETLASTERROROBJECT function that returns you the instance of the System.Exception class, representing the actual exception that has happened.

To properly handle exceptions in an unambiguous way, you must use the exception type, not its name, so it is important to get the actual System.Type representing the exception type.

Sounds easy, but it’s not quite so.

(more…)

Continue ReadingGetting the exception type from the GETLASTERROROBJECT

DotNet Quick Tip: Accessing members with invalid names

  • Post comments:5 Comments
  • Reading time:3 mins read

A friend asked my by e-mail today about a problem he encountered with DotNet interop: how to access a property of an object, if the property name matches a reserved word in NAV. A simplest example is from the Microsoft.Dynamics.Nav.SMTP.SmtpMessage class that comes bundled with NAV 2013.

Consider this piece of code:

Mail := Mail.SmtpMessage;
Mail.To := 'john.doe@noname.no';

If you try to compile this, it will fail. It’s simple: the To property name is invalid in the C/AL context, because it is a reserved word.

So, how do you fix it?

(more…)

Continue ReadingDotNet Quick Tip: Accessing members with invalid names