≡ Menu

Try catch and finally in new Dynamics Ax (aka AX7)

Finally I found that in new Dynamics Ax finally statement introduce in exception handling statement.

try
{
}
catch
{
}
finally
{
}

It means, everything written in finally must be execute. For testing this functionality I just create a runnable class and written following code.

class HelloWorld

{

/// <summary>

/// Runs the class with the specified arguments.

/// </summary>

/// <param name = "_args">The specified arguments.</param>

public static void main(Args _args)

{

ColorDC dc = new ColorDC();

ColorSc Sc = new ColorSc();

 

try

{

dc.parmColorName("Red");

Sc.InsertColor(dc);

dc.parmColorName("Green");

Sc.InsertColor(dc);

} catch (Exception::Error)

{

info("error");

}

finally

{

info("finally");

}

 

 

}

 

}

 

When run the code.

I found Info box in browser as

2016-01-24_12-47-01

{ 0 comments… add one }

Leave a Comment