Much of the code we developed in X ++ classes running on the server layer ( Data Providers reports, processes Batch , SysOperation , …), which is a little uncomfortable when debugging. If we put a breakpoint from the X ++ editor in MorphX in code running on the server, we see how the integrated debugger never stops at this point.
Prepare the development environment for debugging server code from Visual Studio (including the X ++ code, the server always runs as CIL code) forces us to consider a few prerequisites, so I’ll list here to keep on hand when we do need:
Prerequisites and prior considerations:
- Ensure that the code CIL is fully executed without errors. Otherwise, we want to debug the assembly may not be available in its latest version, but the last to be compiled without errors.
- To debug remote code to run Visual Studio as long as Administrator (with elevated privileges by clicking -right> Run as administrator). Otherwise, we will have problems later permissions.
- Remote debugging from Visual Studio must be on the same server where the AOS is installed, indirectly forcing us to use a development environment, because this is not ideal for production OSA configuration.
- AOS configuration option must be on Enable breakpoints to debug X ++ code runing on this server (this is also not recommended in production OSA).
- Associate a process for purifying AOS puts the server in a state extremely unstable , with very significant risk that the service restarts unexpectedly. Therefore it is highly recommended to use a development server isolated not to disturb the other developers.If we use a single AOS for all developers, it may be interesting to take another AOS for remote debugging.
Start the remote debugging:
- Start Visual Studio on the server and Elevated.
- If you are not already showing, show the Application Explorer (from the menu View ), which shows the OSA VS.
- Navigating the Application Explorer and put breakpoints where we want to stop running (add breakpoins in Visual Studio , notMorphX !!).
- If the message appears in the status bar of Visual Studio (at the bottom of the window) “Loading symbols” is best to wait until this process is complete. The first is a slow process; The following times will run much faster.
- Go to menu Debug> Attach to Process
- Activate the checkbox Show processes from all users and show processes for all sessions , select the process Ax32Serv.exe AOS we want debug and press Associate .
- After this process you may be reloaded symbols (X ++ code and assembled AOS CIL is discharged to the session of Visual Studio). All code is downloaded to C: \ Program Files \ Microsoft Dynamics AX \ 60 \ Server \ <NAME AOS> \ bin \ XppIL \ source for Visual Studio has access to the show and we in the editor.
- When you have downloaded all objects, and can run our application and to reach the breakpoint , it will stop at the open session ofVisual Studio (not the debugger MorphX ).
- If you are trying to debug is invoked from an external application, such as a web service, we can have another instance of Visual Studio open to run. In this case it should be a different instance of Visual Studio we use to debug it is associated with OSA.
- If we let all the symbols are downloaded, we can surf the execution routinely, but sometimes the source of some objects will not be available during debugging. In this case we can stop debugging and open the object in the Application Explorer , to make sure thatVisual Studio has downloaded.
- Debugging in Microsoft Dynamics AX 2012 [AX 2012]
- Debugging Managed Code in Microsoft Dynamics AX [AX 2012]