RSS

How can we use DLL in AX

21 May

If you’re using Visual Studio create a new Class Library Project. Implement whatever you need. In the Project Properties you have to sign your Assembly. Only signed Assemblies can be used in Dynamics AX. Change the Build Type to Release and build your Project. You find your DLL in your Projects bin/Release folder. Copy the DLL to the Dynamics AX Client/Bin Directory or register the Assembly in the Global Assembly Cache. Use the gacutil tool to register your Assembly in the GAC.

gacutil /i yourlibrary.dll

Open the AOT in your Dynamics AX Client.

AOT-> References Node. If you have registered the Assembly in the GAC you can choose it from the grid. Otherwise you have to provide the path. If you don’t get any errors it should work.

It is a good idea to use Code Access Permissions with CLR Interop. Otherwise you will get a Best Practice Warning see more detail from below link about this.

https://nasheet.wordpress.com/2012/04/16/error-request-for-the-permission-of-type-interoppermission-failed/

CodeAccessPermission permission;

MyLibrary.MyClass foo;

;

permission = new InteropPermission(InteropKind::CLRInterop);

permission.assert();

foo = new MyLibrary.MyClass();

 

Tags: , , , , , , , ,

9 responses to “How can we use DLL in AX

  1. AX Developer.

    August 22, 2013 at 5:41 am

    Thanks

     
  2. Bill

    January 13, 2014 at 11:28 pm

    Would this cover server side code?

     
    • nasheet

      February 9, 2014 at 12:13 pm

      Yes, It will cover but you have to deploy the dll in the server bin.

       
  3. ownamrsaad

    February 12, 2014 at 11:55 am

    Salam Nasheet

    I did as you mentioned here and when I declare a variable from the library it gives syntax error “Variable MyLibrary has not been declared.” Do I miss anything?

    Thanks and regards,,,

     
    • nasheet

      February 12, 2014 at 12:34 pm

      Did you add the DLL reference in the AOT->references?

       
  4. ownamrsaad

    February 12, 2014 at 12:50 pm

    Yes offcourse I added the DLL to AOT –> References

     
    • cs

      April 2, 2014 at 10:19 pm

      I’m getting the same “variable has not been declared” error. ownamrsaad, were you able to find the cause of this?

       
      • nasheet

        April 3, 2014 at 6:29 am

        Can you please share the code with me as recently, I used some DOT NET DLLs and working fine. I didn’t face any issue like “variable has not been declared”

         
      • cs

        April 3, 2014 at 7:21 pm

        This is my first foray into using a dll in AX and I got the error when I tried to declare an instance of the class described in the dll. Could you possibly point me to a very basic intro to using dlls?

        Thank you!

         

Leave a comment