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 229,021 Most Valuable Professional 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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Forum Structure Changes Coming Soon!

Quick Links

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,734 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,021 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,150

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans