Debugging plugin code for Dynamics 365 / Power Apps

 

Let's say that, in our plugin, we have misspelled some of the field names or we are getting some other exception and we want to debug our plugin. We can take the following steps to debug our plugin:

  1. Install the profiler in our organization by clicking on the Install Profiler button in the plugin registration tool.
  2. Once the profiler has been installed, select the number 1 shown in the following screenshot and click on Start Profiling, as shown in the following screenshot under number 2:

  1. Keep the default settings on the profiling dialog and click on Ok.
  2. Now, try to execute your logic; for example, we registered our plugin upon account creation. When we try to create an account, it will generate a log file with the error details and will store it under the Plugin Profile entity.
  3. You can verify log recording in Dynamics 365 CE from Advanced Find by getting a record from the Plugin Profile entity.
  4. Navigate to Visual Studio| Debug and click on the Attach to Process option. We need to search for the PluginRegistration.exe process and then click on Attach.
  5. Set the breakpoint in our code.
  6. Now, select our plugin step again and click on the Debug button from the toolbar. This will open a dialog where we need to select a log file, as shown in the following screenshot:

  1. Next, we need to select our assembly and click on Start Execution. This will bring focus onto our source code in Visual Studio so that we can start debugging:

With that, we've learned how to debug our plugin code and fix any development issues. 

Here, we learned about writing a sample plugin and how to deploy it. More details on plugin development can be found in the Dynamics 365 CE SDK. Similar to plugin development, we can also develop custom assemblies to extend the capabilities of Dynamics 365 CE workflows, which can be registered to Dynamics 365 CE just like plugins.

These workflow assemblies are not associated with any events; instead, they are used when designing workflows from Workflow Designer.

原文地址:https://www.cnblogs.com/lingdanglfw/p/15007670.html