Use .NET Assemblies in Dynamics AX 3.0 via COM

Dynamics AX 3.0 Axapta.NET is great and since version 4.0 it can be used in Dynamics AX. However, some customers may still run an older version like 3.0 which makes it difficult to integrate AX with other applications. To use .NET assemblies in Dynamics AX 3.0 they have to be COM visible. There are good tutorials online like Mikes Odds and Ends. This article follows the steps presented by Mike to integrate a C# class library that creates HTML code in AX 3.0 SP6.

Code in Visual Studio / C#

  1. Create a new project in Visual Studio
  2. Create a public interface called IHTMLHelper and add a method createHeader(int size,string text)

    namespace ERPCoder
        public interface IHTMLHelper
            string createHeader(int size, string text);

  3. Create a new class and name it HTMLHelper that implements IHTMLHelper
  4. Add a public empty constructor
  5. Add the namespace System.Runtime.InteropServices
  6. Mark the class as [ClassInterface(ClassInterfaceType.None)]
  7. Mark the class and createHeader() method as [ComVisible(true)]

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Runtime.InteropServices;

    namespace ERPCoder
        /// <summary>
        /// HTML Helper class
        /// </summary> 

        public class HTMLHelper : IHTMLHelper
            public HTMLHelper()

            /// <summary>
            /// Creates a HHTML header line
            /// </summary>
            /// <param name="size">Header size between 1 and 6</param>
            /// <param name="text">Header text</param>
            /// <returns>HTML header line</returns>
            public string createHeader(int size, string text)
                if (size < 1 || size > 6)
                    size = 6;

                return String.Format("<H{0}>{1}</H{0}>", size, text);


Modify the Visual Studio Project properties

  1. In Visual Studio open the projects properties from the context menu on the project node in the solution explorer
  2. In the Application Tab open the Assembly Information Dialog enable the COM Visible Property
    Make assembly COM visible
  3. In the Build Tab change the architecture to x86 and enable the Register for COM Interop property
    set x86 and register for COM
  4. In the Build Event add the regasm call as Post-Build event
    %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\regasm $(TargetFileName) /tlb:$(TargetName).lib
  5. Build the project


Include COM in Dynamics AX 3.0

  1. In Dynamics AX 3.0 open from the Menu > Tools > Development Tools > Wizards > COM Class Wrapper Wizard
  2. Click on Browse Button and navigate to the Visual Studio Build Directory
  3. Select the .tlb File and click Next
    Select .TLB in Axapta COM Wrapper Wizard 
  4. Provide a Prefix e.g. ERP
    Provide Prefix in Axapta COM Wrapper Wizard
  5. AX creates two classes to wrap the Interface and implementation class
    Generated COM Wrapper classes in Axapta

Test COM Object

Create a new job, that uses the wrapper class and call the createHeader() method
Test COM Wrapper in X++

About erpcoder
Azure Cloud Architect and Dynamics 365 enthusiast working in Research & Development for InsideAx

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: