error calling a c# dll from ax 2012

hi there

im having a problem with ax 2012

i create a dll in c# that calls a web service , add it to bin folder and as a reference

when i try to call a test method it run and there is no problem but when i try to call the method that has the web service

it generates an error , can you please help me with this

Please tell us more than “it generates an error”. Where and when it gets the error thrown, what the message says, what is the exception type and so on.

What bin folder are you talking about? If you added to client bin only, it will work on client (such as in a job), but not on AOS.

By the way, do you have any reason to add the DLL to the bin folder manually, instead of adding the Visual Studio project to AOT, set its deployment targets and leave the rest to AX?

sorry im new to ax so im trying my best here

  • i dregged it to the client bin

  • i was trying to call a web servicce without writing soo mush x++ so i wrote it in c# and used its dll

The error says thet your code (ClassLibrary1) depends on Newtonsoft.Json assembly, which can’t be found at runtime. It’s not enough if you deploy ClassLibrary, you have to deploy the JSON library as well. This is nothing specific to AX; it’s the same for any .NET program.

The usual place for web service calls is on server, therefore putting libraries to client bin isn’t sufficient.

If you want to understand how you can add VS projects to AOT and what advantages it has, please read Visual Studio Development for Microsoft Dynamics AX on MSDN.

thank you i found the solution for this problem
is just to add assemblyBinding to the project config

i add this code to ax32.exe config






and it worked perfectly

This allows you to use a different version of Newtonsoft.Json at runtime than what you used during development.