简体   繁体   English

调试Dynamics CRM插件

[英]Debugging a Dynamics CRM Plug-in

I'm having trouble debugging a Dynamics CRM Online (2015) plug-in (C#). 我在调试Dynamics CRM Online(2015)插件(C#)时遇到问题。 I'm following the instructions on this MSDN article to attach to a process. 我按照此MSDN文章中的说明附加到进程。 In the Attach To Process window, I select "Show processes from all users" and refresh. 在Attach To Process窗口中,选择“显示所有用户的进程”并刷新。 However, I don't see any of the four service processes listed (I think the plug-in type is "online" in my case). 但是,我没有看到列出的四个服务进程中的任何一个(我认为插件类型在我的情况下是“在线”)。

  • w3wp.exe (while having the CRM Online instance open in IE) w3wp.exe(在IE中打开CRM Online实例时)
  • Microsoft.Crm.Application.Hoster.exe Microsoft.Crm.Application.Hoster.exe
  • CrmAsyncService.exe CrmAsyncService.exe
  • Microsoft.Crm.Sandbox.WorkerProcess.exe Microsoft.Crm.Sandbox.WorkerProcess.exe

I've already deployed and registered the plugin using the plugin registration tool. 我已经使用插件注册工具部署并注册了该插件。 I've never done this before so I may be going about it the wrong way. 我以前从未这样做过,所以我可能会采取错误的方式。 Any ideas? 有任何想法吗?

Per the link you referenced, if you are working with Dynamics CRM Online you cannot attach to any of the CRM processes, since they are not running locally. 根据您引用的链接,如果您使用的是Dynamics CRM Online,则无法附加到任何CRM流程,因为它们不在本地运行。

The first paragraph states (emphasis added by me): 第一段说明(我强调):

The following steps describe how to debug a plug-in executing on Microsoft Dynamics CRM 2015 on-premises. 以下步骤描述如何调试在本地Microsoft Dynamics CRM 2015上执行的插件。 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 . 若要调试在Microsoft Dynamics CRM Online上的沙箱中执行的插件,必须使用[ sic ]跟踪,如本主题后面所述

You will need to use the Plugin Profiler to Debug plugins executing in CRM Online. 您需要使用Plugin Profiler来调试在CRM Online中执行的插件。

From Analyze plug-in performance : 来自Analyze插件的性能

  1. Run the Plug-in Registration tool. 运行插件注册工具。 You can find the tool's executable file in the Tools\\PluginRegistration folder of the SDK. 您可以在SDK的Tools \\ PluginRegistration文件夹中找到该工具的可执行文件。 Download the Microsoft Dynamics CRM SDK package. 下载Microsoft Dynamics CRM SDK包。
  2. Click or tap CREATE NEW CONNECTION to connect to a Microsoft Dynamics CRM server and organization. 单击或点击“创建新连接”以连接到Microsoft Dynamics CRM服务器和组织。 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 . 有关连接到服务器和组织的更多信息,请参阅SDK主题: 演练:使用插件注册工具注册插件
  3. Register a plug-in and step on the Microsoft Dynamics CRM server. 在Microsoft Dynamics CRM服务器上注册插件并单步执行。 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. 在目标组织的工具栏中,选择“安装Profiler”。 You will now see a Plug-in Profiler node in the list. 您现在将在列表中看到Plug-in Profiler节点。
  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. 您可以在显示的“Profiler设置”对话框中选择探查器的执行方式。
  6. Perform the operation in Microsoft Dynamics CRM that causes the plug-in to run. 在Microsoft Dynamics CRM中执行导致插件运行的操作。 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. 如果在“Profiler设置”对话框中选择了“例外”选项,则在插件引发异常并显示“业务流程错误”对话框后,单击“下载日志文件”并保存此文件。 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. 启动Microsoft Visual Studio并将调试器附加到PluginRegistration.exe进程。
  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. 稍微延迟后,插件将使用Microsoft Dynamics CRM服务器传递给它的相同执行上下文执行,调试器将停止在您先前设置的断点上执行。
  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. 此时,您可以更改插件代码,构建它,将调试器重新附加到PluginRegistration.exe进程,然后单击“开始执行”以继续调试会话。 While performing these operations, you do not need to close the Debug an Existing Plug-in form. 执行这些操作时,您无需关闭Debug an Existing Plug-in表单。

You do not need to re-deploy the plug-in to the Microsoft Dynamics CRM server until after you have fixed the code problem. 在修复代码问题之前,无需将插件重新部署到Microsoft Dynamics CRM服务器。 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. 即使您在服务器上有插件的优化版本以及正在调试的计算机上的插件的调试版本,此调试方案仍然有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM