Common error when
using a class that runs on server and references a Visual studio DLL file.
I am trying to consume web service from external systems in
AX. To do this, I have added the references in VS 2010 solution and that in
turn is added to the AOT. I have set the deploy on client and server to yes.
When you add the solution to the AOT, the AX server will store
the relevant DLL and its configuration file to the folder under the application
as below. The highlighted part is the instance name.
C:\Program Files\Microsoft Dynamics AX\60\Server\Lexjet_DEV_AX\bin\VSAssemblies
When you use the reference to the web services in a class,
which is very much simplified in AX 2012 as it gets stored under the VS
references, you may want to execute the class always from server. In my case it
is a batch job so it becomes mandatory for me.
But when my code tries to create a service client, it points
out the configuration path to the client rather than the destination pointed
above.
Second Problem with this path reference is that when you try
updating a service in VS 2010 and update the project to AOT, only the server
folder gets the latest artifacts of the project. Below is a screen that shows
that the last modified date of the client folder is older than the one in
server.
The deploy to client did not work and even though you run
the class from server it takes the client’s path reference in the
createServiceClient method.
Workaround:
Every time you add or update the service reference, you need to copy
the configuration and DLL from server to the client folder.
This is a big overhead when you are developing integration
scenarios and you tend to update the service reference again and again.
You also do not want to refer to the client’s directory in
case of a batch job. This is a big pain when you are migrate your code to other
environments.