Skip to main content

Notifications

Microsoft Dynamics AX forum
Unanswered

AX 2012 R3 Custom DLL .NET

Posted on by 302
Hi,
 
We use AX 2012 R3 for a while. We want to use .NET DLL in our system to interact with third-party systems. X++ doesn't allow certain operartion but  .NET looks like fine. I am new in this part of DLL so I started to TEST how to do the whole process. For this purpose I implemented and easy JsonManager to Serialize / unserialize data. Here the example below. I taked the DLL and I copied to the bin directory in the client side. I imported from the AOT (referenced). I make a test via job using x++. The execution failed when I called JSONManager::SerializeObjectToJson or JSONManager::DeserializeJsonToObject. I don't know if it is something I have to add to the C# code or I need to compile with a certain .NET version or I need to sign it. Or it is something I did wrong in X++. thank you
 
 
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using Newtonsoft.Json;namespace JSON{    public class JSONManager    {        // Serialize an object to JSON        public static string SerializeObjectToJson(object obj)        {            return JsonConvert.SerializeObject(obj);        }        // Deserialize JSON to an object        public static T DeserializeJsonToObject<T>(string json)        {            try            {                return JsonConvert.DeserializeObject<T>(json);            }            catch (JsonReaderException ex)            {                // Handle JSON parsing errors                Console.WriteLine(/Error parsing JSON: {0}/, ex.Message);                return default(T);            }            catch (Exception ex)            {                // Handle other exceptions                Console.WriteLine(/An error occurred: {0}/, ex.Message);                return default(T);            }        }    }}
 
 
 
 
 
  • Martin Dráb Profile Picture
    Martin Dráb 225,000 Super User on at
    AX 2012 R3 Custom DLL .NET
    Please tell us more about the problem than mere "the execution failed". Did you get an exception? If so, what did the message say, what was the exception type and the stack trace?
     
    Which version of .NET Framework have you built your assembly for? Did your X++ job compile correctly?
     
    Also, please post your code once more. This site has a bug that distorts formatting in the first post, but it works in replies.

Helpful resources

Quick Links

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Blog subscriptions now enabled!

Follow your favorite blogs

TechTalk: How Dataverse and Microsoft Fabric powers ...

Explore the latest advancements in data export and integration within ...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 283,682 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,000 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,146

Featured topics

Product updates

Dynamics 365 release plans