Thursday, May 8, 2014

How to use Plugin Profiler to debug Plugins with Plugin Registration Tool in CRM 2011/2013

Hi Guys,

You are a Dynamics CRM 2011/2013 Developer and you need to develop some plugnis to perform some synchronous/asynchronous operations that need realy a plugin development.

You develop your plugins on Visual Studio and you build. You build succesfully your plugins assembly and all seems fine.

You use Plugin Registration Tool (PRT) to register your plugin, steps and images.

And Now you are doing your test on your records to verify if your plugins works fine or not, and like for me, nothing works from the first time :)

So you had a Busines Process Error and you want to know why ?

It means, you should debug your code.

And There is three ways to do it :

- First way : If you are using a OnPremise version of Dynamics CRM 2011/2013 and you have your own development server with Visual Studio:
* you should copy your code in your server
* open it with Visual Studio
* put your breakpoints
* attach w3p process
* And debug

When it's ok you can copy your code, build your plugin assembly and update your register assembly with the new one.
It's the easiest way but every developer don't have a personal development server.

- Second way : If you are using OnPremise version of Dynamics CRM 2011/2013 and you don't have access to your own development server but you have access to a team-owned development server without Visual Studio:
* In this case you should use the remote debugger (we will see this way in an upcoming post)

- Third way : If you are using Online version of Dynamics CRM or OnPremise but you don't have access to your team-owned development server using remote debugger.
So you should use Plugin Profiler.

Plugin Profiler it's a powerful PRT component that allows users to debug plugins. This component should be installed on every organization that need plugins debugging.

Let's Go, there are steps to do when you want to use Plugin Profiler:

1 - Open PRT and connect to your CRM Organization
2 - Click on "Install Profiler" button


3 - Wait a few minutes until Profiler is installed successfully


4 - "Install Profiler" becomes "Uninstall Profiler", and a particular Plug-in Profiler assembly is installed.
Plugin Profiler allows also Workflows profiling.


5 - Now you can use your Profiler, it's a good thing because your creation of contact don't work fine and you want to know why?
In this case, you will search the pre-operation create contact step of your plugin, click on right mouse button and click on "Start Profiling" context menu item.

The dialog window "Profile Settings" appears and you can configure storage settings (in Exception mode or in a specific custom entity(Persist mode)).   


You can also configure the limit number of execution and if you want to include "Secure Configuration" if you are using Secure Configuration in your Step like this:


 Click Ok button in the Profiler Settings dialog box.

6 - return to your CRM website, go to Sales > Contacts


Click "+New" button to create a new contact :


The plugin should change the birthdate year from 5/21/2014 to 5/21/2996. When you click sur Save a Business Process Error with an incomrehensive text appears. You should download the log file and save it in the same folder of the plugin assembly. It's not necessary to save it in the same folder but it make debugging easier.


7 - Now return to your Visual Studio IDE, open your plugin solution, put your breakpoints in your source code, go to Debug menu item and click on "Attach to Process" menu item.

Select PluginRegistration.exe process and click "Attach"



8 - Now return to PRT and stop profiling


9 - It's show time, Click on Debug button.


The Debug screen appears and you should select :
> Profile Location : the error details text file that you already downloaded.
> Assembly Location : the location of the plugin assembly.    


If you have custom Secure or Unsecure configuration you can  add them in the "Secure Configuration" and "Unsecure Configuration" tabs.



 You can also change the isolation mode :


Click on "Start Execution" button and return to your source code in Visual Studio to debug.

Good Luck.

N.JL


5 comments:

  1. Hi Nizar,

    Do you know if you can debug managed solution plugin code for CRM 2015 online ?

    Thanks.

    ReplyDelete
  2. hi , plz write the post for * In this case you should use the remote debugger (we will see this way in an upcoming post)

    ReplyDelete
  3. Great Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot.
    Personal development

    ReplyDelete
  4. I think you have a great article here, But let me share with you all here about my experience with a loan lender called Benjamin Lee who helped me expand my business with his loan company that offered me a loan amount of 600,000.00 USD which I used to upgrade my business months ago. He was really awesome working with him because he a Gentle man with a good heart, a man who can listen to your heart beat and tell you that everything will be OK, when I contacted Mr lee it was on my Facebook page that his advert came up then I visited his office at Michigan to discuss about the loan offer that he and his company render, He makes me understand how all process go then I decided to give a try to it was successful just like he promised, yeah I believe him, I trust him, I rely on him as well about all my project he will be my dear financial officer and I'm glad my business is probably going well and I'm going makes my business growth like grass with his help.he work's with a great investors and guess what? They also give international loans. Is that not awesome to hear when you know a lot of business project are growing up each day by day in your heart hoping that you going to make income of that job to raise money for the project, Ops, then Mr Lee will help you with that, Yes international loan he will help you with that perfectly because I trust him very much for that kind of job, Look don't be shy or shaded give a possible try to Mr lee here his contact : 247officedept@gmail.com

    ReplyDelete
  5. Casino de Monte-Carlo | DrmCD
    Casino 하남 출장안마 de Monte-Carlo. Casino de Monte-Carlo. Address: 675 Gambling St, Monte-Carlo, 춘천 출장안마 CA, 충청북도 출장샵 92077. 평택 출장샵 Phone: (760) 익산 출장샵 947-9901. Website: http://www.casinoreports.ca.

    ReplyDelete