This post is machine-translated. The original post in german language can be found here.

How to use an assembly/DLL in Dynamics AX

To use a DLL in Dynamics AX, the DLL must be added to the References node of the AOT.

This can be achieved by right-clicking on the node and select Add Reference. This opens a dialog where - depending on the "location" of the DLL - the following steps must be taken:

  • If the DLL is already registered in the Global Assembly Cache (GAC), it should already appear in the list where they can be selected using the checkbox on the left and selected with Select now.

    To register a DLL in the GAC, it is necessary that the DLL has been signed.
    They can be achieved via the command line using the following command
    "gacutil / i MyClassLibrary.dll"
  • If the DLL for example, is stored in the BIN directory of the client, you must first select it using the Browse button. Now they should appear in the list where they can be selected using the checkbox on the left and selected with Select.

In both cases, the dialog needs to be confirmed with OK.

From this point, the DLL can be addressed as follows:

static void UseDLL(Args _args)
{
    MyClassLibrary.MyExampleClass myClass;

    new InteropPermission(InteropKind::CLRInterop).assert();

    myClass = new MyClassLibrary.MyExampleClass();
   
    info(myClass.ExampleString());
}

The DLL used in the example looks as follows: 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyClassLibrary
{
    public class MyExampleClass
    {
        public string ExampleString()
        {
            string myString = "Hello World!";

            return myString;
        }
    }
}

Info in MSDN:

How to sign an Assembly
http://msdn.microsoft.com/en-us/library/ms247123(v=vs.90).aspx

How to install an Assembly into the Global Assembly Cache
http://msdn.microsoft.com/en-us/library/dkkx7f79.aspx

These post applies to following versions:
Dynamics AX 2012, Dynamics AX 2009

 
 

 

 
 
 
Posts of the actual month
November 2024
MoTuWeThFrSaSu
 123
45678910
11121314151617
18192021222324
252627282930 
 
© 2006-2024 Heinz Schweda | Imprint | Contact | German version | Mobile version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.