Analyze plug-in performance

 

Applies To: Dynamics CRM 2013

The Plug-in Profiler is a tool that profiles the execution of plug-ins and custom workflow activities for an enhanced debugging experience in Microsoft Visual Studio. This tool, which can be run from the Command Prompt window or from within the Plug-in Registration tool, makes developing custom code against Microsoft Dynamics CRM 2013 and Microsoft Dynamics CRM Online quicker and easier. In addition, users can profile the execution of failing code and send the results to the developer of the code or independent software vendor (ISV) for analysis. The developer can replay the plug-in or custom workflow activity execution and debug the code remotely even when disconnected from the Microsoft Dynamics CRM server.

The tool can be used in either the debug or replay mode. Each of these modes is described in the following sections.

In This Topic

Debug a plug-in using the plug-in profiler

Replay plug-in execution

Run the plug-in profiler standalone

Debug a plug-in using the plug-in profiler

  1. Run the Plug-in Registration tool. You can find the tool’s executable file in the Tools\PluginRegistration folder of the SDK. Download the Microsoft Dynamics CRM SDK package. 

  2. Click or tap CREATE NEW CONNECTION to connect to a Microsoft Dynamics CRM server and organization. For more information on connecting to a server and organization, refer to the SDK topic: Walkthrough: Register a plug-in using the plug-in registration tool.

  3. Register a plug-in and step on the Microsoft Dynamics CRM server. Keep a copy of the debug compiled plug-in assembly on the computer where you are running the tool.

  4. In the toolbar for the target organization, select Install Profiler. You will now see a Plug-in Profiler node in the list.

  5. Select a plug-in step and click Start Profiling in the toolbar to begin profiling. You can choose how the profiler executes in the displayed Profiler Settings dialog.

  6. Perform the operation in Microsoft Dynamics CRM that causes the plug-in to run. For example, if the step is configured for an update to an account, then update an account.

  7. If you have selected the Exception option in the Profiler Settings dialog, after the plug-in throws an exception and the Business Process Error dialog is displayed, click Download Log File and save this file. Alternately, if the plug-in does not throw an exception, click Stop Profiling.

  8. In the Plug-in Registration tool, click Debug.

  9. In the Debug an Existing Plug-in dialog box, provide the requested information in the Setup tab. Enter the location of the previously saved log file in the Profile field. Enter or choose the location of the plug-in assembly and the class name of the plug-in that was executed.

  10. Launch Microsoft Visual Studio and attach the debugger to the PluginRegistration.exe process.

  11. Set a breakpoint in the plug-in code.

  12. Click Start Execution in the Debug an Existing Plug-in dialog box.

  13. After a slight delay, the plug-in will execute using the same execution context that was passed to it by the Microsoft Dynamics CRM server and the debugger will stop execution on the breakpoint that you previously set.

  14. Continue debugging the plug-in as you would normally do. Any traces that the plug-in outputs are shown in the Debug an Existing Plug-in dialog box.

At this point you can alter the plug-in code, build it, re-attach the debugger to the PluginRegistration.exe process, and click Start Execution to continue with your debugging session. While performing these operations, you do not need to close the Debug an Existing Plug-in form.

You do not need to re-deploy the plug-in to the Microsoft Dynamics CRM server until after you have fixed the code problem. This debugging scenario works even if you have an optimized version of the plug-in on the server and a debug version of the plug-in on the computer where you are debugging.

Replay plug-in execution

Replaying plug-in execution does not require a connection to a Microsoft Dynamics CRM server and organization. The advantage of this method is that you can obtain the plug-in execution profile from a customer and debug the plug-in remotely. A restriction of the replay feature is that you cannot change the sequence of calls your plug-in code makes in the debugger while you are debugging.

The replay feature provides the plug-in with a snapshot of the call data and event execution context from the Microsoft Dynamics CRM server. You are getting the same events, GUIDs, and so on from calls to the Organization service but no data is being modified on the server as you debug the plug-in. During the debugging procedure in the previous section, the plug-in actually connects to the server and makes calls in real time.

Replay plug-in execution

  1. Launch Microsoft Visual Studio and attach the debugger to the PluginRegistration.exe process.

  2. Click REPLAY PLUG-IN EXECUTION.

  3. Enter the log and plug-in assembly locations in the dialog box.

  4. Click Start Execution.

  5. Debug the plug-in as you would normally.

Run the plug-in profiler standalone

The profiler can be executed from a Command Prompt window independent of the Plug-in Registration tool. This is useful to obtain the plug-in profile log from a customer's Microsoft Dynamics CRM server to debug a failed plug-in. A developer can then use that log to replay the plug-in's execution in the Plug-in Registration tool and debug the plug-in usingMicrosoft Visual Studio.

Run the plug-in profiler from a command prompt

  1. Open a Command Prompt window and set the working directory to the Tools\PluginRegistration folder in the SDK download.

  2. Type the command: PluginProfiler.Debugger.exe /?.

  3. Review the supported parameter list and re-run the PluginProfiler.Debugger.exe program with the appropriate parameters.

See Also

Developer tools
Solution tools for team development
Plug-in development
Register and Deploy Plug-Ins
Debug a plug-In