I ran into an issue today that the client can’t find the plug-in project that some independent consultants built a year ago. Since they can’t get in touch with the consultants who wrote the plug-in, they have two options to get retrieve the code. One option was rewrite the plug-in from scratch and the other option was to retrieve the plug-in from the CRM database since the plug-ins are registered in the database.
To rewrite the plug-in code would require a lot of effort, so they chose the second option. To retrieve the custom plug-in from CRM database is easy. Here are the steps to do that.
SELECT Content FROM PluginAssemblyBase
WHERE PluginAssemblyId = '[Plugin Guid]'
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);
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);
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!