A few days ago I was challenged with the task of retrieving a Microsoft Dynamics CRM 4.0 Plugin DLL and it's Source Code from the CRM Database. Apparently the contractor that created the Plugin DLL in question forgot to check in the Source Code into Source Control, and after the contractor had left the IT people reformatted the PC's Hard Drive and gave it to another user (so there was no way to get the source code any more). To make it worse, since the Plugin DLL was deployed to Database, there was no actual physical DLL file anywhere to be found on the Server.
Here is how I managed to get not only the DLL in question back, but also its source code:
1. Read content of DLL from PluginAssemblyBase table, “content” column which was stored in Base64 Format: The way Microsoft CRM 4.0 Plugin Deployment to Database works is to read the Binary content of the Plugin DLL and converts it to Base64 String, storing it in the PluginAssemblyBase Database Table, in the "content" column. So one could simply copy the Base64 String from that column using Microsoft SQL Management or a standard Database record read.
2. Converted the Base64 DLL content to Binary using a converter: There are many ways to do this, but the easiest way is to use an online converter like the one HERE to convert the Base64 String to Binary format and save it to file. Make sure to name the resulting DLL file the same as the original DLL was called (you can determine this by reading the Name column of the PluginAssemblyBase table for the record in question).
3. Saved the result of this conversion to a file called NameOfYourDLL.dll: The converter from part 2 allows you to save the resulting binary output to file.
4. Decompiled the resulting dll using a .NET Decompiler: I used Redgate's .NET Reflector to decompile the resulting DLL and get the source code.
5. Obtained the source code and created a new Project in Visual Studio: You just have to expand each class and copy and past each class file to a new physical file in VS.
I hope this information comes in handy to someone else besides me.
Pete Soheil
DigiOz Multimedia
http://www.digioz.com/
2 comments:
Thank you - this has really made my day a lot easier!
You are very welcome Wei. I am glad someone else found it useful.
Post a Comment