Walkthrough: Using the Cross-Reference Tool with Visual Studio Projects

Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

This topic shows you how to use the Cross-reference tool with managed code by creating two C# projects and adding them to the Application Object Tree (AOT).

This walkthrough illustrates the following tasks:

  • Creating the projects in Visual Studio and adding them to the AOT

  • Using the Cross-reference tool to view the cross-reference information

Prerequisites

To complete this walkthrough you will need:

  • Microsoft Dynamics AX with Visual Studio Tools installed

  • Visual Studio 2010

Creating the Projects in Visual Studio

The following procedure explains how to create the projects in Visual Studio and add them to the AOT.

To create the projects

  1. Create a new C# class library project in Visual Studio by selecting File > New > Project.

  2. From the Installed Templates tree, click Visual C# > Windows and select the Class Library template. Accept the default project name, for example, ClassLibrary1.

  3. In Solution Explorer, create and add another C# class library project to the solution by right-clicking the solution and selecting Add > New Project.

  4. Select the Class Library template. Accept the default project name, for example, ClassLibrary2.

  5. In Solution Explorer, click the ClassLibrary1 project and add a project reference to the ClassLibrary2 project by right-clicking and selecting Add Reference. On the Projects tab, select the ClassLibrary2 project.

  6. In Solution Explorer, right-click the solution and select Build Solution.

  7. In Visual Studio, add the ClassLibrary1 and ClassLibrary2 projects to the AOT by following the steps in How to: Add a Visual Studio Project to the AOT.

  8. In Visual Studio, add an X++ class to the ClassLibrary2 project by selecting View > Application Explorer. Expand the Classes node and drag the ChartOfAccounts class to the ClassLibrary2 project.

  9. In Visual Studio, add the following method to Class1 in the ClassLibrary2 project.

    bool getIsBuffer()
            {
                ChartOfAccounts coa;
                bool result;
    
                coa = new ChartOfAccounts();
                                               // Get the class property and return it.
                result = coa.isBuffer();
    
                return result;
            }
  1. In Solution Explorer, right-click the ClassLibrary2 project and select Build.

Using the Cross-Reference Tool

The following procedure explains how to use the Cross-reference tool to view the cross-reference information for the managed code objects that you created. For more information, see Viewing the Cross-Reference System Information.

To use the Cross-reference tool

  1. In Microsoft Dynamics AX, open the AOT, click Visual Studio Projects > C Sharp Projects and select the ClassLibrary1 project.

  2. Right-click and select Add-Ins > Cross-reference > Using (instant view). The Complete cross reference form appears and displays a reference to the ClassLibrary2 project. Cross reference information for managed code is updated immediately when the projects are added to the AOT.

  3. To see the cross-reference information for ClassLibrary2, right-click ClassLibrary2 and select Add-Ins > Cross-reference > Using (instant view). The Complete cross reference form shows the location of the ClassLibrary2.dll assembly and all the locations where the ChartOfAccounts class is used.

  4. To view the cross-reference information in the opposite direction, you must first update the cross-references. To do so, right-click the ClassLibrary2 project and select Add-Ins > Cross-reference > Update.

  5. Then right-click the ChartOfAccounts class and select Add-Ins > Cross-reference > Used by. The Used by form shows you all the managed code that uses the ChartOfAccounts class which is ClassLibrary2 project, in this case.

Tip

If you encounter issues and need to troubleshoot cross-reference information, the assemblies generated by the Cross-reference tool can be found in the directory C:\Users\<username>\AppData\Local\Microsoft\Dynamics AX\CrossReferenceAssemblies.

See also

Cross-References and Visual Studio Projects

Viewing the Cross-Reference System Information