Perform debugging activities
When you're investigating issues in finance and operations apps, you may need to analyze behavior at runtime to understand where logic is failing or producing unexpected results. Debugging allows you to step through code, inspect variables, and validate logic. This unit focuses on how to perform debugging activities using tools available to developers, including debugging locally in Visual Studio and debugging deployed code in cloud environments.
Explore Debugging Tools for Finance and Operations Apps
Finance and operations apps support multiple debugging approaches depending on whether you're validating code locally or troubleshooting issues that only appear after deployment.
Debugging capabilities include:
Debugging code in Visual Studio in Unified Developer Experience (UDE) developer environments.
Debugging deployed code in cloud-hosted environments (CHE) and local VM (running on Hyper-V) – both run as a one box environment.
Attaching the debugger to a running session.
Combining debugging with test framework workflows for issue resolution.
Developers typically debug after documenting and reproducing issues as part of the issue-tracking process covered earlier in the module.
Note
Using TraceParser to locate classes and methods for setting breakpoints can be helpful.
Debugging is on the instance, meaning that all sessions running on the AOS will appear in the debugger (batches, clients etc.). Setting breakpoints should be very specific, and awaiting batch jobs set on hold. The AOS will be stopped for all processes while debugging.
Debug Code Locally Using Visual Studio
Local debugging is useful when building customizations or validating fixes before deployment.
Common tasks include:
Attaching the debugger to the correct user session.
Setting breakpoints to pause code execution.
Stepping through execution (Step Into, Step Over, Step Out).
Reviewing the call stack to understand execution paths.
Inspecting variable values to confirm expected data flow.
Local debugging helps identify issues early before they reach shared testing environments.
Packages to be loaded for debugging can be set in Visual Studio > Dynamics 365 > Options > Dynamics 365 > Debugging. Limiting the number of packages for debugging will make a better debugging experience.
Debug Deployed Code in Cloud Environments
Some issues only appear with production-like data, user roles, or integration behavior. In these cases, debugging needs to occur in a cloud-hosted or UDE developer environment.
Key considerations:
Ensure remote debugging is enabled for the environment.
Attach the debugger to a deployed session using supported tools.
Verify permissions required for remote debugging.
Use telemetry, performance logs, and diagnostic signals when troubleshooting.
Debugging deployed code is appropriate when behavior can't be reproduced locally.
Apply Debugging to Common Scenarios
Here are some examples of debugging you might need to do.
Debug custom services (endpoints and deployment)
Custom services in Dynamics 365 Finance and Operations can be SOAP or JSON-based. Use the same debugging techniques you learned earlier—setting breakpoints, inspecting variables, and stepping through code—to identify issues in endpoint configurations and deployment. To debug a service:
Ensure the service is correctly deployed to the cloud runtime.
Verify endpoint configurations, including authentication and connectivity settings.
Use Visual Studio debugging tools to set breakpoints and monitor service execution.
Note
Always authenticate and connect to the environment using your Microsoft Dataverse credentials before debugging.
Debug extensions in Dynamics 365 Finance and Operations
Extensions allow developers to customize Dynamics 365 functionality. Apply the debugging workflow you learned earlier to extensions by setting breakpoints in event handlers, class extensions, and form extensions:
Set breakpoints in the extension code using Visual Studio.
Use the "Launch debugger" option to attach the debugger to the running AOS process.
Refresh the browser window to reload the URL and hit breakpoints without restarting the debugger.
Note
Use the SysUserSetup form to test form extensions and observe breakpoint behavior.
Resolve issues with chain of command (CoC) in Dynamics 365
Chain of Command (CoC) enables method wrapping and extending functionality. Debugging CoC issues involves:
Ensuring proper implementation of next calls.
Accessing protected members correctly.
Verifying method wrapping logic.
Set breakpoints in overridden methods and use Visual Studio debugging tools to analyze execution flow.
Handle errors in extensibility scenarios
Error handling in extensibility scenarios ensures robust customizations. Best practices include:
Validating table extensions for data integrity.
Debugging data entity extensions for proper data flow.
Testing form extensions to ensure UI functionality.
Use Application Insights for monitoring and telemetry to identify and resolve errors efficiently.
Tip
Synchronize the database for all models without deploying new changes using the "Synchronize database" option in Dynamics 365.
Debug integrations (APIs and data sync)
Integration patterns in Dynamics 365 include synchronous and asynchronous methods such as OData, batch data APIs, and custom services. Apply your debugging skills by setting breakpoints where integration code executes, inspecting variable values during data transfer, and reviewing call stacks to trace integration flows. Common errors in these patterns might involve:
Incorrect API configurations.
Data synchronization issues.
Authentication failures.
To troubleshoot:
Check API documentation for proper configurations.
Use Application Insights to monitor and diagnose integration issues.
Debug using Visual Studio by setting breakpoints and analyzing logs.