web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

adding reference to AX 2012.

(0) ShareShare
ReportReport
Posted on by

Hello.

I created a dll on C#.

I want to add and use it on AX.

So I put the dll on folder: C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin

and add reference to it on reference node on AX.

Now I want to use it.

I just add a code.

MYReferenceLib l; // (MyReferenceLib is the library) and then I got the error:

Variable MYReferenceLib has not been declared.

1. What shall I have to do in order the code will compile?

2. Can I add reference and refer it on the client side (also add the dll on the client side)?

Thanks :)

*This post is locked for comments

I have the same question (0)
  • Bilal Issa Profile Picture
    4,370 on at

    Hi,

    open visual studio -> create new  project -> Class Library -> right click add to AOT, then click properties for the project -> Deploy to client Yes.

    Regards,

    Bilal

  • Community Member Profile Picture
    on at

    No.

    Still I cannot compile the code.

    Here is my code on C#:

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Runtime.InteropServices;

    namespace SPLWinAPI2

    {

       class GeneralAPI

       {

           public GeneralAPI()

           {

           }

           private delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);

           [DllImport("user32.dll")]

           [return: MarshalAs(UnmanagedType.Bool)]

           private static extern bool EnumChildWindows(IntPtr hwndParent, EnumWindowsProc lpEnumFunc, IntPtr lParam);

           static bool getChildWindows(IntPtr hwndParent, EnumWindowsProc lpEnumFunc, IntPtr lParam) {

               EnumWindowsProc childProc = new EnumWindowsProc(EnumWindow);

               EnumChildWindows(hwndParent, lpEnumFunc, lParam);

               return false;

           }

           private static bool EnumWindow(IntPtr handle, IntPtr pointer)

           {

               return false;

           }

           public int testc()

           {

               return 123;

           }

       }

    }

    I created a library dll. Copied it to: C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin

    (I have tried to copy it to server bin folder - same problem).

    Stop+Start the service (should I?)

    Here is reference in code in AX:

    SPLWinAPI2 b; // this is not compileable.

    SPLWinAPI2.GeneralAPI c; // this is not compileable.

    Thanks :)

  • Suggested answer
    Joris dG Profile Picture
    17,775 on at

    Your C# class is not declared public.

  • Community Member Profile Picture
    on at

    OK, I didn't notice that.

    Now I am getting exception: CLRObject object not initialized.

    What may be the reason for that?

  • Suggested answer
    Joris dG Profile Picture
    17,775 on at

    That depends on your calling code from AX. If you can share the X++ code, we can review.

  • Community Member Profile Picture
    on at

    Anyway, about the exception - I have managed.

    BTW, I want the code run on client and not on server. How can I ensure that?

    Thanks.

  • Community Member Profile Picture
    on at

    Hello Etian ,

    what's your solution for  "CLRObject object not initialized" ??

  • Martin Dráb Profile Picture
    237,967 Most Valuable Professional on at

    The error says only that an exception occurred in a .NET class constructor.

    There is no single universal solution for all possible exceptions in all classes in the world. You must look at your what error you're getting in which class in your particular scenario.

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

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans