Microsoft Dynamics 365 Blog

One of the nice features added with Dynamics AX 2009 is the support for 64bit (x64) for the Dynamics AX 2009 Application Object Server and the Dynamics AX 2009 .NET Business Connector.

However when you have some existing X++ that you are now migrating to Dynamics AX 2009, you might run into an issue when you are using the DLLFunction kernel class and try to execute the code on a 64bit AOS.

When you are trying to use the DLLFunction kernel class on a 64bit AOS the execution of the method call will result in the following error message:

Function ‘FunctionName’ in DLL library ‘DLLName’ has caused an exception.

When you are executing exactly the same code on a 32bit AOS, the execution will work (assuming the parameters of the DLLFunction were set correctly).

Background of this issue is, that on 64bit the DLLFunction kernel class itself is not implemented in Dynamics AX 2009.

If you are in a situation where you need to make a call to an external WinAPI DLL, you need to look for alternatives:

  1. Can the call to the external DLL moved to the Client tier? As the Dynamics AX 2009 Client is still 32bit, the DLLFunction kernel class is here existing as it was in the past.
  2. Does there exist an equivalent of the WinAPI DLL? If the WinAPI DLL is used to communicate with an external component maybe different communication interfaces exist, like COM Components or .NET Assemblies. Those can still be used.
  3. Can a .NET wrapper Assembly be created? If no existing equivalent .NET Assembly is available you might be able to create yourself a wrapper you can reference in Dynamics AX 2009. Inside the wrapper you can simply pass on the calls to the WinAPI DLL. For more information see Consuming Unmanaged DLL Functions and Platform Invoke Tutorial.
–author: Alexander Lachner
–editor: Alexander Lachner
–date: 20/10/2009

We're always looking for feedback and would like to hear from you. Please head to the Dynamics 365 Community to start a discussion, ask questions, and tell us what you think!