Share via


Use of ILSpy in Dynamics 365

If you are part of any Dynamics migration project, you sometimes can face this typical issue.

Your customer's previous vendor provided the source code without supplying all the required Proprietary DLLs. This applies to Visual Studio solutions for plugins or custom workflow activities. When you open these solutions, they will not compile and give errors about missing references. 

In these cases, there is a workaround "ILSpy". ILSpy is an open -source .NET assembly browser and decompiler. This can be used to view source code and namespaces for a Dynamics CRM plugin/custom workflow DLLs.

https://2.bp.blogspot.com/-o5XeIvUhPaU/WiwuIhZDecI/AAAAAAAABbc/ZBYf94nwG3cZwNinI7SPaZu5kwqzV_pDQCLcBGAs/s1600/23.PNG

Download ILSpy

  • Go to http://ilspy.net and download the binaries. Unzip it in any location on your computer. You can use the ILSpy to de-compile a plugin solution and browse through all namespaces.

https://3.bp.blogspot.com/-u152pXlp0D4/WiwvUP0eUSI/AAAAAAAABbk/XId4g52ITRII_JRr2zWiXIJpHEP3JYgfwCLcBGAs/s1600/24.PNG

Unzip ILSpy Binaries

  • Create a blank solution in source CRM. Include Plugin or workflow assembly. Do not include any SDK message processing steps.

https://4.bp.blogspot.com/-Xjq_bRAL8tU/Wi17dx1pkvI/AAAAAAAABb4/D8jnd5vJFlMpq_Tor4DZlcB84945ASW0QCLcBGAs/s640/25.PNG

Create Solution with Plugin Assembly

  • Export the solution and save it on your computer. Unzip the solution.

https://4.bp.blogspot.com/-w2FDPHFphMQ/Wi1_geN9K_I/AAAAAAAABcE/HiDh-sGJ8WkuC4eZ-hdOjSX9PqVVkybZwCLcBGAs/s640/26.PNG

Export Solution

  • Go to a folder which has the plugin. Open ILSpy.exe. Drag and drop the plugin to ILSpy.

https://3.bp.blogspot.com/-9NPRLlZdgl4/Wi2Ag4r0A6I/AAAAAAAABcU/zGvZOZ2t-NACijpekPw64zv3GIZu0rKAgCLcBGAs/s1600/27.PNG

Open Folder with Plugin Assembly

https://1.bp.blogspot.com/-FmD5dtZlQMA/Wi2Ag46g3eI/AAAAAAAABcM/LM3uxmQgc60A18U_NrJ4dtc6dmJg7hGKACEwYBhgL/s1600/28.PNG

Open ILSpy.exe

https://1.bp.blogspot.com/-hDDje32oy-s/Wi2Ag7olvgI/AAAAAAAABcQ/p92q3ZcPFrI1hkyHhHX68tk2EtCtAU6VACEwYBhgL/s1600/29.PNG

Drag and Drop the Plugin Assembly to ILSpy

As you can see all the namespaces used in a plugin are extracted. This way even if you do not have the DLLs, you can create references in the Visual Studio solution by including all namespaces and the code within. Hopefully, this will help compile the code.