Tuesday, 12 April 2016

Consuming External DLL from NEW Dynamics AX (AX7)

Hello there,

Whats the big difference between AX 2012 and AX7 on consuming external DLLs.  We do add the DLLs as the references at the Reference folder and copy the DLLs over to a specified folder and just use it.  Yes, it works for both the versions, but the difference comes here on building the external DLLs and the path to copy the DLLs.

If you have used ManagedInterop DLL to consume AX 2012 business logic from within the DLL, then that model would not work with AX7.  See my another blog that explains on consuming AX7 Business logic from outside AX here.  You will need to change the approach that fits AX7.  And, the Project assembly should NOT be signed.  You will likely to get run-time errors if it is signed.  See here for more details.

Also, you will need to choose the .NET Framework Version as 4.5 at the Project properties.  I've tried using the below and above versions, but was not working.

Then comes the folder path to copy the DLLs over for the application to consume.  The DLLs need to be copied over to the following folders:

  • C:\Packages\ApplicationSuite\bin
  • C:\CustomerServiceUnit\DOBind\Packages\Cloud\AosWebApplication\AosWebApplication.csx\roles\AosWeb\approot\bin

We've upgraded our solution to AX7 and the model is residing under the ApplicationSuite folder and hence, the respective DLLs need to go under ApplicationSuite\Bin folder.  You can also copy over the PDB files over there if you want to debug.  This is the case with AX7 Local VM, cloud hosted ones is the different story.

Note:  This is the case with AX7 RTW (7.0.1265.3015).

Cheers!

Limitations of Consuming External DLL from NEW DYNAMICS AX (AX7)

Often the times that we need to consume external DLL from within AX7 by adding the DLLs as the references in the References node of the Application Explorer.  One of the limitations that I have encountered is that external DLL cannot be consumed if it is a SIGNED one.  We will likely to get some run-time errors.  Remove the assembly sign, build the solution and use the unsigned DLLs.

Note: This is the case with AX7 RTW (7.0.1265.3015) and the previous CTPs.

Consuming NEW Dynamics AX (AX 7) Business Logic from outside AX

Many a times, we come across with this - accessing AX Business logic from a Third-party application.  I assume that to be C# for this blog.  There exists different ways doing this.

  1. We can create Public Data Entities inside AX and consume the same thru OData Endpoints.  
  2. We can create Services inside AX and consume the same by adding Service References.
  3. We can add reference to the AX7 DLL and consume the respective business logic.  

I'm focusing on the #3 in this blog.

In AX 2012, this can be achieved using the DLL Microsoft.Dynamics.AX.ManagedInterop.  But this is not the case with AX7.  As every model that we create leads to assemblies, we need to directly add reference to the respective assemblies.  For example, Microsoft ships AX7 with Fleet Management module.  If we need to get access to a table in Fleet Management module, say "FMRental" from a .NET application, then the following DLLs needs to be referenced in the Visual Studio Project.

  • Dynamics.AX.FleetManagement
  • Microsoft.Dynamics.AX.Xpp.Support
  • Microsoft.Dynamics.AX.Xpp.AxShared

The DLLs Microsoft.Dynamics.AX.Xpp.Support and Microsoft.Dynamics.AX.Xpp.AxShared can be found in the C:\Packages\Bin folder.

Let say, you have upgraded your solution from AX 2012 to AX7 and the upgraded model is residing under the ApplicationSuite folder.  Then, you will need to add reference to the Dynamics.AX.ApplicationSuite DLL.

Here is the simple code example that calls the "CustomerName" method of the FMRental table,













Thanks!




Wednesday, 1 October 2014

SSRS Report Deployment Error - The SSRS report with design doesn't contain any RDL

The SSRS report <report name> with design <design name> doesn't contain any RDL

Encountered this issue while deploying the newly created SSRS report in AX 2012.
Follow this, and then restart the Reporting Services to fix this issue. 

Go To Line number feature in AX 2012

Here is the code snippet, which would help in locating the line number in a string control which has got multiple lines.

static void gotoLineNum(FormStringControl   _control,   int _gotoLine)
{
    int lineCount;

    int i;
    int gotoLineNum;
    int lengthTotal;
    int selectToPos;
    str lineText;

    #define.SPACE(' ')

    lineCount = _control.getLineCount();
    gotoLineNum = _gotoLine;

    for (i = 0; i<= lineCount-1; i++)
    {
        if (i == gotoLineNum-1)
        {
            break;
        }
        if (i == 0)
        {
            lineText = #SPACE + _control.getLine(i);
        }
        else
        {
            lineText = strRep(#SPACE, 2) + _control.getLine(i) ;
        }

        lengthTotal += strLen(lineText);
    }

    lineText =  #SPACE + _control.getLine(i);
    selectToPos = lengthTotal + strLen(lineText);

    lengthTotal = (i==0) ? 0 : lengthTotal+1;

    _control.setSelection(lengthTotal, selectToPos);

    _control.setFocus();
}

Tuesday, 9 September 2014

Missing Labels in infolog and message box

Missing Labels

I have worked on a weird issue where labels are found missing on infolog and message box.  It works for few users and not for few.  There was only one AOS installed/configured for the environment.  There has been many ways to troubleshoot this issue especially where there is more than one AOS configured for the environment.  


But here the case is bit different as we have only one AOS configured.

Finally, we found the problem is due to different language associated to certain users where labels are missing, as the labels were not created for the respective language.

Simple solution, but effective!!!  Have fun :)


Monday, 8 September 2014

Debugging

Debugging

Many a times, we end up putting the debugger on certain X++ code and getting frustrated that the debugger is not up during the execution.  For example, while debugging Wizard based development code, Reports, etc.  There are many ways to handle this situation.  One of the easiest ways is use the keyword "breakpoint;" instead of marking the line by hitting F9 for debugging.