调试 Dynamics CRM 插件
Debugging a Dynamics CRM Plug-in
我在调试 Dynamics CRM Online (2015) 插件 (C#) 时遇到问题。我正在按照 this MSDN article 上的说明附加到进程。在附加到进程 window 中,我 select "Show processes from all users" 并刷新。但是,我没有看到列出的四个服务进程中的任何一个(我认为插件类型在我的例子中是"online")。
- w3wp.exe(在 IE 中打开 CRM Online 实例时)
- Microsoft.Crm.Application.Hoster.exe
- CrmAsyncService.exe
- Microsoft.Crm.Sandbox.WorkerProcess.exe
我已经使用插件注册工具部署并注册了插件。我以前从未这样做过,所以我可能会以错误的方式去做。有什么想法吗?
根据您引用的 link,如果您正在使用 Dynamics CRM Online,则无法附加到任何 CRM 流程,因为它们不在本地 运行。
第一段说(重点是我加的):
The following steps describe how to debug a plug-in executing on
Microsoft Dynamics CRM 2015 on-premises. To debug a plug-in that
executes in the sandbox on Microsoft Dynamics CRM Online, you must
using [sic] tracing as described later in this topic.
您将需要使用插件探查器来调试在 CRM Online 中执行的插件。
来自Analyze plug-in performance:
- 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.
- 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.
- 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.
- In the toolbar for the target organization, select Install Profiler. You will now see a Plug-in Profiler node in the list.
- 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.
- 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.
- 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.
- In the Plug-in Registration tool, click Debug.
- 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.
- Launch Microsoft Visual Studio and attach the debugger to the PluginRegistration.exe process.
- Set a breakpoint in the plug-in code.
- Click Start Execution in the Debug an Existing Plug-in dialog box.
- 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.
- 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.
我在调试 Dynamics CRM Online (2015) 插件 (C#) 时遇到问题。我正在按照 this MSDN article 上的说明附加到进程。在附加到进程 window 中,我 select "Show processes from all users" 并刷新。但是,我没有看到列出的四个服务进程中的任何一个(我认为插件类型在我的例子中是"online")。
- w3wp.exe(在 IE 中打开 CRM Online 实例时)
- Microsoft.Crm.Application.Hoster.exe
- CrmAsyncService.exe
- Microsoft.Crm.Sandbox.WorkerProcess.exe
我已经使用插件注册工具部署并注册了插件。我以前从未这样做过,所以我可能会以错误的方式去做。有什么想法吗?
根据您引用的 link,如果您正在使用 Dynamics CRM Online,则无法附加到任何 CRM 流程,因为它们不在本地 运行。
第一段说(重点是我加的):
The following steps describe how to debug a plug-in executing on Microsoft Dynamics CRM 2015 on-premises. To debug a plug-in that executes in the sandbox on Microsoft Dynamics CRM Online, you must using [sic] tracing as described later in this topic.
您将需要使用插件探查器来调试在 CRM Online 中执行的插件。
来自Analyze plug-in performance:
- 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.
- 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.
- 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.
- In the toolbar for the target organization, select Install Profiler. You will now see a Plug-in Profiler node in the list.
- 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.
- 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.
- 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.
- In the Plug-in Registration tool, click Debug.
- 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.
- Launch Microsoft Visual Studio and attach the debugger to the PluginRegistration.exe process.
- Set a breakpoint in the plug-in code.
- Click Start Execution in the Debug an Existing Plug-in dialog box.
- 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.
- 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.