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
Create a new C# class library project in Visual Studio by selecting File > New > Project.
From the Installed Templates tree, click Visual C# > Windows and select the Class Library template. Accept the default project name, for example, ClassLibrary1.
In Solution Explorer, create and add another C# class library project to the solution by right-clicking the solution and selecting Add > New Project.
Select the Class Library template. Accept the default project name, for example, ClassLibrary2.
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.
In Solution Explorer, right-click the solution and select Build Solution.
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.
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.
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;
}
- 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
In Microsoft Dynamics AX, open the AOT, click Visual Studio Projects > C Sharp Projects and select the ClassLibrary1 project.
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.
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.
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.
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.