Debug Plugins with Dataverse Browser – Quick Recap

Hi Folks,

This post is for all who are working on D365 Model Driven Apps and mainly Plugins.

Yes, you saw it right, in this blog post, we will see how can debug plugin without using our favorite plugin profiler which is very widely used from quite some time by everyone working on Plugins for Dynamics 365. All this is done by a tool called Dataverse Browser, which is not yet on XrmToolBox. Please note that there were some limitations as detailed in limitation section below.

Here are 3 simple steps to follow..

  1. Install Dataverse Browser
  2. Attach the Debugger
  3. Run your actual operation.
  4. Step into your code and debug it.

The tool embeds a web browser based on Chromium. It works by translating the Web API requests to SDK requests. Then it analyzes if plugin steps are registered on the message and it loads them, make them run locally. All other requests are sent to the Dataverse, so that the plugins are interacting with the real database.

Download the latest source code of Dataverse browser here.

Next extract the zip file downloaded as highlighted below

Extract the zip file downloaded, open Dataverse.Browser Application as highlighted below.

In the popup window, click on More info as highlighted below…

Then run the application anyway…you will be presented with a window where you can select the environment. Going forward, any time you want to open Dataverse browser, just open the Dataverse.Browser.exe and choose the environment as below.

Click on New, enter the details as above and key in the details.

  • Enter the settings of your environment:
    • A name meaningful for you
    • The host name of your instance (without the https://)
    • The path to the plugins assembly file (the dll). For a better experience, it should be compiled in debug mode with the pdb file generated.

Then click Go.

You just need to Authenticate to your instance.

Once Authenticated to the respective model driven apps, all the Web API requests sent to Dataverse will be shown as below.

I have following Plugin Libraries registered.

Next step is to choose the instance and perform the respective operation which triggers the Plugin. So, in here, I will perform an update to the Account entity from the Dataverse Browser which triggers the Plugin.

Once an update is performed, a Web API request gets recorded in the Dataverse browser as highlighted below.

Since the Plugin is in Post Operation, i.e. Stage number is 40

Just expand the Patch Request, you should see two operations on 30, 40, but area of interest here is for the Plugin which was registered on stage 40.

Make sure you open the Visual Studio and perform the below steps from Dataverse Browser.

Attach the debugger from Dataverse Browser by clicking on the Plug Symbol as below which will show the list of debugger options available for you to select from. Here I have selected Execute Plugins, plugin will be invoked. You can either select any of the three options as presented below.

1.Do not execute plugins – recommended when you want to debug without actually triggering your plugin logic. i.e. With this approach even you can check the code in Production environment.

2. Execute plugins/Execute plugins with auto break – recommended when you want to debug by triggering your actual plugin, this is recommended in case your plugin code had changed recently and in Development environments.

Just select Ecellors Demo – Microsoft Visual Studio: Visual Studio Professional 2022 version which will launch an existing Visual studio 2022 as below in break mode. Next click on Continue as highlighted below or press Click F5 on your keyboard.

This shows you that the debugger has been attached when you navigate to Dataverse Browser asking you to place your breakpoints.

Now just place breakpoints in your code in Visual Studio. Just go back to Dataverse Browser and click on Ok on the Diaglog box.

Perform the operation which triggers the Plugin from Dataverse Browser itself, this will hit the break point in Visual Studio from where you can debug your plugin.

As you might have observed, your code need not throw exception in order to debug, you could do similarly to the way you would debug using Profiler. But here just that you don’t need to deploy the latest code to the Dataverse just for debugging purpose.

This gives a lot more flexibility eases the way you debug plugins.

Limitions:

  • There is no support for transactions.
  • When plugins are triggered because of a server-side operation, they will not be run locally.
  • For many reasons, behavior will never be perfectly similar to the one when plugins are executed on server side.

Happy debugging, I hope you found this post useful…

References:

Dataverse Dev Browser

Cheers,

PMDY

Connecting to your Dataverse instance to run SQL Queries without using XrmToolBox

Hi Folks,

Do you know that you can connect to your Dataverse DB right from your old toolbox SSMS, an express version would be more than enough to try out. Possibly we didn’t think of, but yes, we can…so let’s see that in this blog post.

Open SSMS..

1.Select Server type as Database Engine

2. Server name as the environment URL from your Power Platform Admin Center as below.

3. So key in those details as below, make sure to Select Authentication method as Azure Active Directory – Universal with MFA option.

Once you click on Connect, you will be prompted for authentication via browser.

Once your Sign-In is successful, you will be able to see.

That’s it, how simple it was connecting to your Dataverse instances…

Having said that it’s easy to connect to Dataverse, not all operations performed using normal transact SQL are supported here using Dataverse SQL. You could see it says Read-Only besides the instance name, that means that you don’t have any capabilities to modify from SQL.

Because Dataverse SQL is a subset of Transact-SQL. If you want to see what statements are supported and what not, just go ahead to this link to find out.

This opens a whole lot of opportunities to explore, so don’t forget to check this out.

References:

Dataverse SQL and Transact SQL

Cheers,

PMDY

Cloning feature branch from Azure DevOps repository doesn’t get you the latest changes..?

Hi Folks,

This blog post is just an observation from my experiences of getting the latest version of code from a remote development feature branch cloned from the main branch. I didn’t observe this my first sight and because of couple of other issues, I had overseen this, spent over a half an hour and I had to giggle after knowing this.

If you were aware, as of my last update in September 2021, Azure DevOps and Visual Studio have been integrated to support seamless code collaboration and version control.

So usually in day-to-day activities of any Developer working Microsoft Technology stack, Pull, Push, Clone, Merge of Azure DevOps repository directly from Visual Studio is quite common.

Usually, to clone a repository from Azure DevOps, you follow the below steps.

Step 1: Open Visual Studio of any
version, preferably after VS 2017
Step 2: Click on Clone the repository.

Step 3: Enter the Azure DevOps
Repository URL and provide the path in the prompt.

Step 4: Select your respective
repository and click on Sign in

Step 5: Once you are done click on
Clone, all your source code is now available in your IDE (Visual Studio)

There might be cases when you check and see you were not able to get the latest changes from your feature branch, those were present in the repo but not in your Visual Studio. Closing the Visual Studio and redoing the Cloning process didn’t help. Then I thought it could be because of Cache of Visual Studio in my PC, so I tried clearing cache following my favorite blog post written earlier in this blog. Even this didn’t help either, thanks to my buddy Mallikarjun C who gave me the clue and here it goes.

Whenever you were cloning a solution using above approach, ideally you will be checked out to the Main branch and not the feature branch which you were expecting to be checked out to, as Main is set as Default branch.

If you just see below, it wasn’t checked out to Develop, instead it was main. By default, with this approach, you will by default checked out to main branch.

Hence you were seeing the changes of the main branch itself and not the Develop branch.

Instead of this, as I learned I suggest you clone directly to your favorite IDE from Azure DevOps itself in few clicks.

Step 1: While you are in your respective branch in Azure DevOps, click on Clone option as highlighted below.

Step 2: It will then ask you to choose the IDE to which you can download the source code.

Hope this helps someone figuring this out..

Cheers,

PMDY