web
You’re offline. This is a read only version of the page.
close
Skip to main content
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)
  • Martin Dráb Profile Picture
    236,240 Most Valuable Professional on at
    RE: adding reference to AX 2012.

    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.

  • Community Member Profile Picture
    on at
    RE: adding reference to AX 2012.

    Hello Etian ,

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

  • Community Member Profile Picture
    on at
    RE: adding reference to AX 2012.

    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.

  • Suggested answer
    Joris dG Profile Picture
    17,775 on at
    RE: adding reference to AX 2012.

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

  • Community Member Profile Picture
    on at
    RE: adding reference to AX 2012.

    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
    RE: adding reference to AX 2012.

    Your C# class is not declared public.

  • Community Member Profile Picture
    on at
    RE: adding reference to AX 2012.

    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 :)

  • Bilal Issa Profile Picture
    4,370 on at
    RE: adding reference to AX 2012.

    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

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
Guy Terry Profile Picture

Guy Terry 2 Moderator

#1
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans