using .dll file in x++ code

I have added RR assembly for .NET (RR.dll) in References in Dynamics AX 2012 .i used this .dll file in a class.

Then I moved all the code to a method with RunOn property set to server as I dont want to run it on client side. Now, when I execute the same X++ code it gives me the following errors.

Assembly containing type "RR.eft.constant.eftservice" is not referenced.

Object 'CLRObject' could not be created

Initially, during testing on client method, I placed .dll file in my .../Client/Bin folder and added reference from my AOT.

Next I placed it in .../Server/.../Bin folder and added reference from my server's AOT and then tested the method with RunOn property set to server but it is not working and gave me the above mentioned errors.

Please help me as I have been working around this issue for a week and could not get any solution. 

  • One potential problem is that AX client is 32-bit process and AOS is 64-bit process. Also, even if your assembly is all right, it may not be loaded if some of its dependencies can't be loaded by any reason.

  • In reply to Martin Dráb:

    Hi,

       Thanks For the Reply,what is the solution for that.

    Thanks in Advance,

    sudha

  • In reply to Manasa sudha:

    It depends on what's the problem.

    If you have a .DLL built for another processor architecture, built it again for the right one. If you can't, you'll need another process (e.g. another service communicating with AOS).

    If it's caused by some referenced assembly, you have to find which one it is and identify why it's not loaded (missing on AOS machine, 32-bit or so).

  • In reply to Martin Dráb:

    Hi,

    Thanks for the reply.i called this dll in a job.it is working there but in my class it is trowing error.can u please help me in this issue.

    Thanks in Advance,

    sudha

  • In reply to Manasa sudha:

    I don't know anything about the library nor your system; you're the only one who can analyze what's wrong.

    First check processor architecture of the .dll (you can use CofFlags.exe, for example). Then check what components are required by the .dll. Often you can see something obvious what's not in the machine on question. If you don't see anything suspicious, try Assembly Binding Log Viewer.

  • How to Call a .net C# sharp code in Ax2012

     

    1.open visual studio 2010 create a new C# project in that open class library write the following code

     

    using System.Text;

     

    namespace AXCS

    {

        public class TestingMyDLL1

        {

            public string Greet(string name)

            {

                return "Hello " + name;   

            }

        }

    }

     

    2.Bulid the solution 

     

    3.go visualstudio projects---> copy dll files

     

    4.program files(X84)-->microsoft dynamics--->client--->bin---> paste    Dll files

     

    5.open AOT-->go referencess --->.add reference--> add that dll files

     

    6.Go to jobs--> Add new job write that following code

     

    static void testingNETCode(Args _args)

    {

        MyDLL1.TestingMyDLL1          testingDll;

        InteropPermission           permission;

        str s;

        ;

     

        try

        {

            permission = new InteropPermission(InteropKind::DllInterop);

            permission.assert();

     

            //System.Windows.Forms.MessageBox::Show("Hello pavani","AX",System.Windows.Forms.MessageBoxButtons::OKCancel);

     

            testingDll = new MyDLL1.TestingMyDLL1();

            s = testingDll.Greet("Pavani");

            info(s);

        }

        catch

        {

            error('Error executing DLL code');

        }

    }

     

     

    7. Execute job

  • In reply to Manindra:

    No fix from November?

    Even MVP can't help?

  • In reply to Alex Judovs:

    Alex, what fix are you looking for? Does it belong here? Shouldn't you create a new thread for your question?

  • In reply to Martin Dráb:

    Hi Drab

    We are also facing the same issue as we are able to call the dll from Job and not from the class.We have built in both 32 and 64 Bit CPU.Please share your thought on this..

    Thanks
    Hari
  • In reply to Chanikya:

    I already did that above. There are more reasons why the assembly can't be loaded, such as that you miss certain referenced assemblies on AOS. The Assembly Binding Log Viewer will help you if you don't see anything wrong.

  • In reply to Chanikya:

    Hi Hari,

    Please try to use the dll Microsoft.Dynamics.AX.ManagedInterop for getting the reference.

    Regards,
    Parthiban
  • In reply to Parthiban:

    Hi Pathiban,

    What do you exactly mean by saying use "Microsoft.Dynamics.AX.ManagedInterop" as reference? Where? in AX code? or the DLL that was created?

    Please let us know.

    Thanks.
Related
Recommended