Friday, September 24, 2010

Retrieve Plug-in/Custom Workflow Activity DLL from Database

Some times we used get some scenarios to register the dll into DB and after wards we will loose the dll and source code.

the following may help to get the dll atleast and some extend the source code also.

1.Retrieve the Plug-in encoded string from the Organization MSCRM database. The plug-ins are stored in the Plugin PluginAssemblyBase table.


SELECT Content FROM PluginAssemblyBase
WHERE PluginAssemblyId = '[Plugin Guid]'

2.Copy and paste the Content string into a text file.

3.Write a simple C# command line application to convert the plug-in string to DLL.


string inputFileName = "Plugin.txt";
string outputFileName = "Plugin.dll";

FileStream fileStream = File.Open(fileName, FileMode.Open);
byte[] buffer = new byte[fileStream.Length];
fileStream.Read(buffer, 0, buffer.Length);
fileStream.Close();
ASCIIEncoding encoding = new ASCIIEncoding( );
this.buffer = encoding.GetString(buffer);

FileStream fileStream = new FileStream(outputFileName, FileMode.Create);
byte[] buffer = Convert.FromBase64String(this.buffer);
fileStream.Write(buffer, 0, buffer.Length);
fileStream.Close();

4.After you retrieved the DLL from the database, then you may use .Net Reflector to extract the code from this plug-in.

That’s it! Just in case you run into the same situation that you have to retrieve your plug-in or custom workflow activity from MSCRM database, you can follow the steps above. I hope this helps!


Sudhanshu

No comments:

Post a Comment