Plugin Class Code Recovery using XRMToolBox & C# DotPeek. - CloudFronts

Plugin Class Code Recovery using XRMToolBox & C# DotPeek.

In an ideal Dynamics 365 (Dataverse) project, plugin source code lives safely in a version-controlled repository, flows cleanly through Azure DevOps pipelines, and is always recoverable. In reality, many of us inherit environments where that discipline didn’t exist.

I recently worked with a customer where:

  • a.Plugin assemblies were already deployed and working in the environment.
  • b. The original development had been done by a different developer.
  • c. DevOps pipelines and repositories no longer contained the plugin solution or it’s code.
  • d. Only the compiled assemblies existed in the Plugin Registration Tool.

This created a common but uncomfortable challenge in the Dynamics 365 world:
How do you maintain, debug, or enhance plugins when the source code is lost?

Rewriting everything from scratch was risky and time-consuming. Guessing behavior based on runtime results wasn’t reliable. Fortunately, Dynamics 365 and the .NET ecosystem give us a practical and effective alternative.

Using XrmToolBox and JetBrains dotPeek, it is possible to recover readable C# plugin code directly from the deployed assembly. (Though the C# Class code recovered won’t be 100% exact, as the variable names would be different and generic; it is only suitable for close logic, structure & functional recovery)

The Practical Solution

The approach consists of two main steps:

  1. Extract the plugin assembly (.DLL) from the Dataverse environment
  2. Decompile the assembly back into readable C# code

This does not magically restore comments or original formatting, but it does give a working, understandable code that closely reflects the original plugin logic.

Tools Used

  • a. XrmToolBox – XrmToolBox is a free Windows utility that provides a collection of tools & Custom Plugins to simplify administration, customization, and management of Microsoft Dataverse and Dynamics 365 environments.
  • b. Assembly Recovery Tool (XrmToolBox plugin) – Used to download plugin assemblies
  • c. JetBrains dotPeek – A .NET decompiler that reconstructs C# code from DLLs

Step 1: Extract the Plugin Assembly from Dataverse

1. Connect to the Environment

  • a. Open XrmToolBox
  • b. Connect to the target Dynamics 365 / Dataverse environment using valid credentials

2. Load the Assembly Recovery Tool

  • a. In XrmToolBox, search for Assembly Recovery Tool
  • b. Open the tool
  • c. It will list all plugin assemblies currently registered in the environment

3. Download the DLL

  • a. Create a local folder where you want to store the assembly
  • b. Select the required plugin assembly from the list
  • c. Download the .dll file to your local folder

At this point, you have successfully recovered the compiled plugin assembly exactly as it exists in the environment.

Step 2: Decompile the DLL Using JetBrains dotPeek

1. Open dotPeek

  • a. Launch JetBrains dotPeek
  • b. Drag and drop the downloaded .dll file into the left-hand panel

2. Explore the Decompiled Code

dotPeek will:

  • a. Analyze the assembly
  • b. Reconstruct namespaces, classes, and methods
  • c. Display readable C# source code

One can now browse through:

  • a. Plugin classes
  • b. Execute methods
  • c. Business logic
  • d. Service calls and context handling

This is usually more than enough to understand how the plugin works.

3. Export to a Visual Studio Project (Optional but Recommended)

One of dotPeek’s most powerful features is Export to Project:

  • a. Right-click on a class or the entire assembly
  • b. Choose Export to Project
  • c. dotPeek will generate a complete Visual Studio solution

This gives you a proper .csproj with class files that you can open, build, and extend.

Possibilities with the Recovered Code

Once you have the decompiled C# code, several options open up:

1. Rebuild the Plugin Assembly

  • a. Create or use the exported Visual Studio class library
  • b. Fix references if needed
  • c. Compile a new plugin assembly

2. Re-register the Plugin

  • a. Use the Plugin Registration Tool (PRT)
  • b. Register the newly compiled assembly
  • c. Replace or upgrade the existing plugin steps safely

3. Maintain or Enhance Functionality

  • a. Debug logic issues
  • b. Add new conditions or validations
  • c. Extend functionality without guessing behavior
  • d. Align the code with current business requirements

Important Considerations

  • a Decompiled code may not include:
    • 1. Original comments
    • 2. Exact variable names
    • 3. Formatting preferences
  • b However, business logic is preserved
  • c Always verify licensing and contractual permissions before modifying recovered code
  • d Treat this as a recovery and maintenance technique-not a substitute for proper source control

Key Takeaway

Losing plugin source code does not mean losing control of your Dynamics 365 solution.

With XrmToolBox’s Assembly Recovery Tool and JetBrains dotPeek, you can:

  • a. Recover deployed plugin assemblies
  • b. Reconstruct readable C# code
  • c. Rebuild, maintain, and enhance existing plugins
  • d. Avoid risky rewrites and blind troubleshooting

There are chances while working in Dynamics 365 technologies, that a developer might face this situation. Knowing this technique can save days-or weeks-of effort and give your customer confidence that their system remains fully supportable.

We hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfronts.com


Share Story :

SEARCH BLOGS :

FOLLOW CLOUDFRONTS BLOG :


Secured By miniOrange